PHP Classes

File: src/Script/Call/JsObjectCall.php

Recommend this page to a friend!
  Packages of Thierry Feuzeu   Jaxon   src/Script/Call/JsObjectCall.php   Download  
File: src/Script/Call/JsObjectCall.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: 5 months ago
Size: 986 bytes
 

Contents

Class file image Download
<?php

namespace Jaxon\Script\Call;

/**
 * JsObjectCall.php
 *
 * Factory for a Javascript object.
 *
 * @package jaxon-core
 * @author Thierry Feuzeu
 * @copyright 2024 Thierry Feuzeu <thierry.feuzeu@gmail.com>
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
 * @link https://github.com/jaxon-php/jaxon-core
 */

use Jaxon\Script\Action\Attr;
use
Closure;

class
JsObjectCall extends AbstractJsCall
{
   
/**
     * The class constructor
     *
     * @param Closure|null $xExprCb
     * @param string $sJsObject
     */
   
public function __construct(?Closure $xExprCb, protected string $sJsObject)
    {
       
parent::__construct($xExprCb);
    }

   
/**
     * Get the call to add to the expression
     *
     * @return Attr
     */
   
protected function _exprCall(): Attr
   
{
       
// If the value is '', return the js "window" object, otherwise, the corresponding js object.
       
return Attr::get($this->sJsObject ?: 'window');
    }
}