public function init() { $data = ParamsExpander::expand($this, ['class', 'updatable']); foreach ($data as $name => $value) { $this->getEntity()->{$name} = $value; } }
public function init() { $data = ParamsExpander::expand($this, ['class']); $meta = new EmbeddedMeta($data); $meta->single = true; $this->getEntity()->embedded = $meta; $this->getEntity()->propagateEvents = true; $this->getEntity()->owned = true; $this->getEntity()->decorators[] = EmbeddedDecorator::class; }
protected function getDbRefMeta() { $data = ParamsExpander::expand($this, ['class', 'updatable']); $refMeta = new DbRefMeta($data); if (!$refMeta->class) { $refMeta->class = $this->getMeta()->type()->name; } $this->getEntity()->updatable = $refMeta->updatable; return $refMeta; }
public function init() { $data = ParamsExpander::expand($this, ['class']); $class = ''; if (isset($data['class'])) { $class = $data['class']; } // Log only, as it is designed as soft-fail if (empty($class) || !ClassChecker::exists($class)) { (new Signal())->getLogger()->warning(sprintf('Class not found for SignalFor annotation on model `%s`', $this->getMeta()->type()->name)); return; } NameNormalizer::normalize($class); $this->getEntity()->signalFor[] = $class; }
public function init() { $data = ParamsExpander::expand($this, ['orderField']); if (empty($this->getEntity()->related)) { $relMeta = new RelatedMeta(); } else { $relMeta = $this->getEntity()->related; } foreach ($data as $key => $val) { $relMeta->{$key} = $val; } if (empty($relMeta->sort)) { $relMeta->sort = [$relMeta->orderField => SortInterface::SortAsc]; } $this->getEntity()->related = $relMeta; }
public function init() { $params = ['class']; if (is_string($this->value)) { $this->class = $this->value; } elseif (is_array($this->value)) { foreach (array_keys($this->value) as $key) { if (!is_numeric($key)) { $params[] = $key; } } } else { throw new \UnexpectedValueException(sprintf("Expected class name (for @Validator) for field `%s` of model `%s`, got: `%s`", $this->getEntity()->name, $this->getMeta()->type()->name, $this->value)); } $this->proxy = ClassValidatorProxy::class; $this->getEntity()->validators[] = new ValidatorMeta(ParamsExpander::expand($this, $params)); }
public function init() { $params = ['class']; if (is_string($this->value)) { $this->class = $this->value; } elseif (is_array($this->value)) { foreach (array_keys($this->value) as $key) { if (!is_numeric($key)) { $params[] = $key; } } } $config = ParamsExpander::expand($this, $params); if (empty($config['class'])) { throw new UnexpectedValueException(sprintf('@Sanitizer expects class name for model `%s` field `%s`', $this->getMeta()->type()->name, $this->getEntity()->name)); } elseif ($config['class'] !== 'None' && !ClassChecker::exists($config['class']) && !ClassChecker::exists(sprintf('%s\\%s', PassThrough::Ns, $config['class']))) { throw new UnexpectedValueException(sprintf('Class `%s` for @Sanitizer not found on model `%s` field `%s`', $config['class'], $this->getMeta()->type()->name, $this->getEntity()->name)); } $this->getEntity()->sanitizer = $config; }
/** * * @return stdClass */ protected function _getMeta() { /** * TODO Does not expand params on SimpleTree */ $data = ParamsExpander::expand($this, ['class', 'join', 'sort', 'updatable']); $relMeta = new stdClass(); foreach ($data as $key => $val) { $relMeta->{$key} = $val; } if (empty($relMeta->class)) { $relMeta->class = $this->getMeta()->type()->name; } if (empty($relMeta->join)) { $relMeta->join = null; } if (empty($relMeta->sort)) { $relMeta->sort = ['_id' => 1]; } return $relMeta; }
/** * * @return RelatedMeta */ protected function _getMeta() { $data = ParamsExpander::expand($this, ['class', 'join', 'sort', 'updatable']); if (empty($this->getEntity()->related)) { $relMeta = new RelatedMeta(); } else { $relMeta = $this->getEntity()->related; } foreach ($data as $key => $val) { $relMeta->{$key} = $val; } if (!$relMeta->class) { $relMeta->class = $this->getMeta()->type()->name; } if (empty($relMeta->join)) { throw new UnexpectedValueException(sprintf('Parameter `join` is required for `%s`, model `%s`, field `%s`', static::class, $this->getMeta()->type()->name, $this->getEntity()->name)); } if (empty($relMeta->sort)) { $relMeta->sort = ['_id' => SortInterface::SortAsc]; } return $relMeta; }
public function init() { $this->proxy = RegexProxy::class; $this->getEntity()->validators[] = new ValidatorMeta(ParamsExpander::expand($this, ['pattern', 'allowEmpty', 'not', 'message', 'skipOnError', 'on', 'safe', 'enableClientValidation', 'except', 'proxy'])); }
public function init() { $this->proxy = RequiredProxy::class; $this->getEntity()->validators[] = new ValidatorMeta(ParamsExpander::expand($this, ['requiredValue', 'strict', 'message', 'skipOnError', 'on', 'safe', 'enableClientValidation', 'except', 'proxy'])); }
public function init() { $this->proxy = CompareProxy::class; $this->getEntity()->validators[] = new ValidatorMeta(ParamsExpander::expand($this, ['compareAttribute', 'compareValue', 'strict', 'allowEmpty', 'operator', 'message', 'skipOnError', 'on', 'safe', 'enableClientValidation', 'except', 'proxy'])); }
public function init() { $this->proxy = BooleanProxy::class; $this->getEntity()->validators[] = new ValidatorMeta(ParamsExpander::expand($this, ['trueValue', 'falseValue', 'strict', 'allowEmpty', 'message', 'skipOnError', 'on', 'safe', 'enableClientValidation', 'except', 'proxy'])); }
public function init() { $this->proxy = StringProxy::class; $this->getEntity()->validators[] = new ValidatorMeta(ParamsExpander::expand($this, ['max', 'min', 'is', 'tooShort', 'tooLong', 'allowEmpty', 'encoding', 'message', 'skipOnError', 'on', 'safe', 'enableClientValidation', 'except', 'proxy'])); }
public function init() { $this->proxy = NumberProxy::class; $this->getEntity()->validators[] = new ValidatorMeta(ParamsExpander::expand($this, ['integerOnly', 'allowEmpty', 'max', 'min', 'tooBig', 'tooSmall', 'message', 'skipOnError', 'on', 'safe', 'enableClientValidation', 'except', 'proxy'])); }
public function init() { $this->proxy = UniqueProxy::class; $this->getEntity()->validators[] = new ValidatorMeta(ParamsExpander::expand($this, ['allowEmpty', 'className', 'attributeName', 'criteria', 'message', 'skipOnError', 'on', 'safe', 'enableClientValidation', 'except', 'proxy'])); }