Login   Register  
PHP Classes

File: examples/kernel/core/TObject/mergeProperties.php

Recommend this page to a friend!
  Classes of ASCOOS CMS   Ascoos OS   examples/kernel/core/TObject/mergeProperties.php   Download  
File: examples/kernel/core/TObject/mergeProperties.php
Role: Example script
Content typex: text/plain
Description: Example script
Class: Ascoos OS
A PHP Web 5.0 Kernel for decentralized web and IoT
Author: By
Last change: Update of examples/kernel/core/TObject/mergeProperties.php
Date: 1 month ago
Size: 1,999 bytes
 

Contents

Class file image Download
<?php
/**
 * @ASCOOS-NAME : Ascoos OS
 * @ASCOOS-VERSION : 26.0.0
 * @ASCOOS-SUPPORT : [email protected]
 * @ASCOOS-BUGS : https://issues.ascoos.com
 *
 * @desc <English> Demonstrates merging properties with different strategies using the mergeProperties method.
 * @desc <Greek> ??????????? ?? ?????????? ????????? ?? ???????????? ??????????? ??????????????? ?? ?????? mergeProperties.
 *
 * @since PHP 8.2.0
 */

use ASCOOS\OS\Kernel\Core\TObject;

// <English> Declare global AOS_LOGS_PATH for log directory
// <Greek> ??????? ?? global ????????? AOS_LOGS_PATH ??? ??? ???????? ??????????
global $AOS_LOGS_PATH;

// <English> Initialize properties array with configuration
// <Greek> ???????????? ?????? ????????? ?? ??????????
$properties = [
   
'name' => 'TestObject',
   
'config' => ['host' => 'localhost']
];

// <English> Create a new TObject instance with properties
// <Greek> ?????????? ???? instance ??? TObject ?? ?????????
$object = new TObject($properties);

// <English> Define new properties to merge
// <Greek> ??????? ???? ????????? ??? ??????????
$newProperties = [
   
'config' => ['port' => 3306],
   
'version' => 260000
];

// <English> Merge properties with 'merge' strategy
// <Greek> ?????????? ????????? ?? ?? ?????????? 'merge'
$object->mergeProperties($newProperties, 'merge');

// <English> Output merged properties
// <Greek> ???????? ????????????? ?????????
print_r($object->getProperties()); // Outputs: ['name' => 'TestObject', 'config' => ['host' => 'localhost', 'port' => 3306], 'version' => 260000]

// <English> Free resources
// <Greek> ???????????? ?????
$object->Free($object);
?>