PHP Classes

File: src/App/NodeComponent.php

Recommend this page to a friend!
  Packages of Thierry Feuzeu   Jaxon   src/App/NodeComponent.php   Download  
File: src/App/NodeComponent.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Jaxon
Call PHP classes from JavaScript using AJAX
Author: By
Last change:
Date: 4 months ago
Size: 1,706 bytes
 

Contents

Class file image Download
<?php

namespace Jaxon\App;

use
Jaxon\Di\Container;
use
Jaxon\Plugin\Request\CallableClass\ComponentHelper;
use
Stringable;

abstract class
NodeComponent extends Component\AbstractComponent
{
    use
Component\HelperTrait;
    use
Component\NodeResponseTrait;
    use
Component\AjaxResponseTrait;
    use
Component\ComponentTrait;

   
/**
     * @inheritDoc
     */
   
final protected function initComponent(Container $di, ComponentHelper $xHelper): void
   
{
       
$this->setHelper($xHelper);
       
$this->setNodeResponse($di);
       
$this->setAjaxResponse($di);
    }

   
/**
     * @return string|Stringable
     */
   
abstract public function html(): string|Stringable;

   
/**
     * Called before rendering the component.
     *
     * @return void
     */
   
protected function before(): void
   
{}

   
/**
     * Called after rendering the component.
     *
     * @return void
     */
   
protected function after(): void
   
{}

   
/**
     * Set the attached DOM node content with the component HTML code.
     *
     * @return void
     */
   
final public function render(): void
   
{
       
$this->before();
       
$this->node()->html((string)$this->html());
       
$this->after();
    }

   
/**
     * Clear the attached DOM node content.
     *
     * @return void
     */
   
final public function clear(): void
   
{
       
$this->node()->clear();
    }

   
/**
     * Show/hide the attached DOM node.
     *
     * @return void
     */
   
final public function visible(bool $bVisible): void
   
{
       
$bVisible ? $this->node()->jq()->show() : $this->node()->jq()->hide();
    }
}