PHP Classes

File: src/App/Component/NodeResponseTrait.php

Recommend this page to a friend!
  Packages of Thierry Feuzeu   Jaxon   src/App/Component/NodeResponseTrait.php   Download  
File: src/App/Component/NodeResponseTrait.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,108 bytes
 

Contents

Class file image Download
<?php

namespace Jaxon\App\Component;

use
Jaxon\Di\Container;
use
Jaxon\Response\NodeResponse;

trait
NodeResponseTrait
{
   
/**
     * @var NodeResponse
     */
   
protected $nodeResponse = null;

   
/**
     * @var string
     */
   
protected $overrides = '';

   
/**
     * @param Container $di
     *
     * @return void
     */
   
private function setNodeResponse(Container $di): void
   
{
       
// Each component must have its own reponse object.
        // A component can override another one. In this case,
        // its response is attached to the overriden component DOM node.
       
$this->nodeResponse = $di->newNodeResponse($this->rq($this->overrides ?: ''));
    }

   
/**
     * Get the component response
     *
     * @return NodeResponse
     */
   
final protected function node(): NodeResponse
   
{
        return
$this->nodeResponse;
    }

   
/**
     * Set the component item.
     *
     * @param string $item
     *
     * @return self
     */
   
final public function item(string $item): self
   
{
       
$this->node()->item($item);
        return
$this;
    }
}