Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: True MVC blocks using DTO's #1008

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 54 additions & 54 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions wp-content/plugins/core/functions/templates.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php declare(strict_types=1);

use Tribe\Project\Blocks\Block_Component;
use Tribe\Project\Blocks\Contracts\Block_Model;
use Tribe\Project\Templates\Components\Deferred_Component;

if ( ! function_exists( 'tribe_template_part' ) ) {
Expand Down Expand Up @@ -31,3 +33,18 @@ function defer_template_part( string $slug, ?string $name = null, array $args =
return new Deferred_Component( $slug, $name, $args );
}
}

if ( ! function_exists( 'tribe_render_block' ) ) {
/**
* Render a block manually by passing in your custom populated model.
*
* @param string $block_class The FQCN to the block's Block_Config class.
* @param \Tribe\Project\Blocks\Contracts\Block_Model $model The populated model for which you wish to render.
*
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
function tribe_render_block( string $block_class, Block_Model $model ): void {
tribe_project()->container()->get( Block_Component::class )->render( $block_class, $model );
}
}
Loading