forked from symfony/ux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
152 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\LiveComponent; | ||
|
||
use Symfony\Component\PropertyAccess\Exception\ExceptionInterface as PropertyAccessExceptionInterface; | ||
use Symfony\UX\LiveComponent\EventListener\DeferLiveComponentSubscriber; | ||
use Symfony\UX\TwigComponent\ComponentFactory; | ||
use Symfony\UX\TwigComponent\ComponentRendererInterface; | ||
use Symfony\UX\TwigComponent\Event\PostMountEvent; | ||
use Symfony\UX\TwigComponent\Event\PreMountEvent; | ||
use Symfony\UX\TwigComponent\Event\PreRenderEvent; | ||
|
||
/** | ||
* @author Simon André <[email protected]> | ||
* | ||
* @internal | ||
*/ | ||
class LiveComponentFactory | ||
{ | ||
public function __construct( | ||
private ComponentFactory $inner, | ||
) { | ||
} | ||
|
||
protected function onPreMount(PreMountEvent $event) | ||
{ | ||
// model binding parser | ||
|
||
// DataModelLivePropsSubscriber | ||
// data-model="live" | ||
// $event->setData($data); | ||
} | ||
|
||
/** | ||
* @param PostMountEvent $event | ||
* @return void | ||
* | ||
* @see DeferLiveComponentSubscriber | ||
*/ | ||
protected function onPostMountLazy(PostMountEvent $event) | ||
{ | ||
// extraData(loading, loading-tag)... | ||
// $event->setData($data); | ||
} | ||
|
||
/** | ||
* @param PostMountEvent $event | ||
* @return void | ||
* | ||
* @see QueryStringInitializeSubscriber | ||
*/ | ||
protected function onPostMountQueryString(PostMountEvent $event) | ||
{ | ||
// AddLiveAttributes | ||
// $event->setTemplate($template); | ||
// $event->setVariables($variables); | ||
// | ||
// | ||
// $queryStringData = $this->queryStringPropsExtractor->extract($request, $metadata, $event->getComponent()); | ||
// | ||
// $component = $event->getComponent(); | ||
// | ||
// foreach ($queryStringData as $name => $value) { | ||
// try { | ||
// $this->propertyAccessor->setValue($component, $name, $value); | ||
// } catch (PropertyAccessExceptionInterface $exception) { | ||
// // Ignore errors | ||
// } | ||
// } } | ||
} | ||
} |
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,72 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\UX\LiveComponent; | ||
|
||
use Symfony\UX\LiveComponent\EventListener\ResetDeterministicIdSubscriber; | ||
use Symfony\UX\TwigComponent\ComponentRendererInterface; | ||
use Symfony\UX\TwigComponent\Event\PostRenderEvent; | ||
use Symfony\UX\TwigComponent\Event\PreRenderEvent; | ||
|
||
/** | ||
* @author Simon André <[email protected]> | ||
* | ||
* @internal | ||
*/ | ||
class LiveComponentRenderer implements ComponentRendererInterface | ||
{ | ||
public function __construct( | ||
private ComponentRendererInterface $inner, | ||
) { | ||
} | ||
|
||
public function createAndRender(string $name, array $props = []): string | ||
{ | ||
$this->inner->createAndRender($name, $props); | ||
} | ||
|
||
protected function onPreRender(PreRenderEvent $event): ?string | ||
{ | ||
// AddLiveAttributes | ||
// $event->setTemplate($template); | ||
// $event->setVariables($variables); | ||
} | ||
|
||
/** | ||
* @see DeferLiveComponentSubscriber | ||
*/ | ||
protected function onPreRenderLoading(PreRenderEvent $event) | ||
{ | ||
// change template | ||
// $event->setTemplate($template); | ||
|
||
// $variables['loadingTemplate'] = self::DEFAULT_LOADING_TEMPLATE; | ||
// $variables['loadingTag'] = self::DEFAULT_LOADING_TAG; | ||
// $variables['loading'] = $mountedComponent->getExtraMetadata('loading'); | ||
// $variables['componentTemplate'] = $componentTemplate; | ||
// | ||
// $event->setVariables($variables); | ||
} | ||
|
||
/** | ||
* @param PostRenderEvent $event | ||
* @return void | ||
* | ||
* @see ResetDeterministicIdSubscriber | ||
*/ | ||
protected function postRender(PostRenderEvent $event) | ||
{ | ||
// $event->setHtml($html); | ||
// if (!$this->componentStack->getCurrentComponent()) { | ||
// $this->idCalculator->reset(); | ||
// } | ||
} | ||
} |