Files
vivespos-landing/modules/system/traits/PropertyContainer.php
avives 1f72193a64
Some checks are pending
Module sub-split / Sub-split (push) Waiting to run
feat: VivesPOS landing on Winter CMS 1.2 — theme + plugin + Dockerfile
- Base: wintercms/winter branch 1.2 (full framework)
- Theme vivespos: Canvas 7 + Bootstrap 5 CDN, custom CSS
- Layout: deferred GTM/GA4 tracking, JSON-LD SoftwareApplication
- Partials: hero (offline-first), features, modes (offline/nube toggle),
  screenshots, pricing (3 planes), comparison, FAQ, CTA
- Plugin VivesPOS.Site with ContactForm
- Dockerfile: PHP 8.2 Apache, port 80, healthcheck
- Added winter/wn-pages, blog, sitemap, seo plugins
- Active theme set to vivespos
2026-08-21 19:29:00 -06:00

122 lines
3.2 KiB
PHP

<?php namespace System\Traits;
/**
* Property container trait
*
* Adds properties and methods for classes that could define properties,
* like components or report widgets.
*
* @package winter\wn-system-module
* @author Alexey Bobkov, Samuel Georges
*/
trait PropertyContainer
{
/**
* @var array Contains the object property values.
*/
protected $properties = [];
/**
* Validates the properties against the defined properties of the class.
* This method also sets default properties.
* @param array $properties The supplied property values.
* @return array The validated property set, with defaults applied.
*/
public function validateProperties(array $properties)
{
$definedProperties = $this->defineProperties() ?: [];
/*
* Determine and implement default values
*/
$defaultProperties = [];
foreach ($definedProperties as $name => $information) {
if (array_key_exists('default', $information)) {
$defaultProperties[$name] = $information['default'];
}
}
$properties = array_merge($defaultProperties, $properties);
return $properties;
}
/**
* Defines the properties used by this class.
*
* This method should be overriden in your extended class and return an array of properties that your class uses,
* with the keys of the array being the name of the properties, and the values being an array of property
* parameters.
*
* Example:
* return [
* 'propertyName' => [
* 'title' => 'Property name',
* 'description' => 'Property description',
* 'default' => 'Default value'
* ],
* ];
*
* @return array
*/
public function defineProperties()
{
return [];
}
/**
* Sets multiple properties.
* @param array $properties
* @return void
*/
public function setProperties($properties)
{
$this->properties = $this->validateProperties($properties);
}
/**
* Sets a property value
* @param string $name
* @param mixed $value
* @return void
*/
public function setProperty($name, $value)
{
$this->properties[$name] = $value;
}
/**
* Returns all properties.
* @return array
*/
public function getProperties()
{
return $this->properties;
}
/**
* Returns a defined property value or default if one is not set.
* @param string $name The property name to look for.
* @param string $default A default value to return if no name is found.
* @return mixed The property value or the default specified.
*/
public function property($name, $default = null)
{
return array_key_exists($name, $this->properties)
? $this->properties[$name]
: $default;
}
/**
* Returns options for multi-option properties (drop-downs, etc.)
* @param string $property Specifies the property name
* @return array Return an array of option values and descriptions
*/
public function getPropertyOptions($property)
{
return [];
}
}