/** * @param LiteObject|IMappedObject $object * @param IValuesProcessorContainer $container * @return array */ private static function getFields(LiteObject $object, IValuesProcessorContainer $container) { if ($object instanceof IMappedObject) { $data = $object->getObjectData(); } else { $data = $object->toArray(); } $className = get_class($object); if ($container->has($className)) { $data = $container->get($className)->toRawValues($data); } return $data; }
/** * @param Package $p */ public function __construct(Package $p) { parent::__construct(); $this->_p->Package = $p; $this->_p->Unchanged = new ResourceCollection(); $this->_p->CompileTarget = new ResourceCollection(); }
/** * @param string $name */ public function __construct($name) { parent::__construct(); $this->_p->Name = $name; $this->_p->Path = explode(self::PACKAGE_PATH_SEPARATOR, $name); $this->_p->Requires = new ResourceCollection(); $this->_p->Inscribed = new ResourceCollection(); $this->_p->Styles = new ResourceCollection(); $this->_p->Scripts = new ResourceCollection(); $this->_p->Views = new ResourceCollection(); }
/** * @param LiteObject[] $objects * @return array */ protected function objectsToData(array $objects) { if ($this->hasMapper()) { $data = $this->getMapper()->getArray($objects); foreach ($data as $key => $object) { $data[$key] = array_diff_key($object, array_flip($this->getIgnoreFields())); } } else { $data = LiteObject::allToArray($objects, [], $this->getIgnoreFields()); } return $data; }
/** * @param string $name * @param mixed $value */ public function __set($name, $value) { if ($this->isRestricted($name)) { parent::__set($name, $value); return; } if (!isset($this->modified[$name])) { $oldValue = $this->{$name}; } parent::__set($name, $value); $newValue = $this->{$name}; if (isset($oldValue)) { if ($oldValue !== $newValue) { $this->modified[$name] = $oldValue; } } else { if ($newValue === $this->modified[$name]) { unset($this->modified[$name]); } } }
/** * @param LiteObject $object * @param array $keyFields * @return bool */ public function updateObjectByFields(LiteObject $object, array $keyFields) { return (bool) $this->updateByFields($object->toArray([], $keyFields), $object->toArray($keyFields)); }
/** * @param array $data */ public function __construct(array $data = []) { parent::__construct(); $this->fromArray($data); }