public function __construct($kwargs) { if (!isset($kwargs['rel']) || isset($kwargs['rel']) && $kwargs['rel'] === null) { $kwargs['rel'] = ManyToManyRel::createObject(['fromField' => $this, 'to' => ArrayHelper::getValue($kwargs, 'to'), 'through' => ArrayHelper::getValue($kwargs, 'through'), 'throughFields' => ArrayHelper::getValue($kwargs, 'throughFields'), 'dbConstraint' => ArrayHelper::getValue($kwargs, 'dbConstraint', true)]); } $this->hasNullKwarg = ArrayHelper::hasKey($kwargs, 'null'); parent::__construct($kwargs); }
public function __construct($kwargs) { $kwargs['unique'] = true; if (!isset($kwargs['rel']) || isset($kwargs['rel']) && $kwargs['rel'] == null) { $kwargs['rel'] = OneToOneRel::createObject(['fromField' => $this, 'to' => ArrayHelper::getValue($kwargs, 'to'), 'toField' => ArrayHelper::getValue($kwargs, 'toField'), 'parentLink' => ArrayHelper::getValue($kwargs, 'parentLink'), 'onDelete' => ArrayHelper::getValue($kwargs, 'onDelete', Delete::CASCADE)]); } parent::__construct($kwargs); }
public function toLevel($level) { $level = $level === null ? static::ERROR : $level; if (is_string($level)) { $level = ArrayHelper::getValue($this->levelsMap, strtolower($level)); } return $level; }
public function __construct($kwargs) { if (!isset($kwargs['rel']) || isset($kwargs['rel']) && $kwargs['rel'] == null) { $kwargs['rel'] = ManyToOneRel::createObject(['fromField' => $this, 'to' => ArrayHelper::getValue($kwargs, 'to'), 'toField' => ArrayHelper::getValue($kwargs, 'toField'), 'parentLink' => ArrayHelper::getValue($kwargs, 'parentLink'), 'onDelete' => ArrayHelper::getValue($kwargs, 'onDelete', Delete::CASCADE)]); } $this->toField = ArrayHelper::getValue($kwargs, 'toField'); $this->fromField = 'this'; parent::__construct($kwargs); }
public function execute() { if (ArrayHelper::isEmpty(ArrayHelper::getValue($this->qb->getQueryParts(), 'select', null))) { $this->qb->select('*'); } if (ArrayHelper::isEmpty(ArrayHelper::getValue($this->qb->getQueryParts(), 'from', null))) { $this->qb->from($this->model->meta->dbTable); } return $this->qb->execute()->fetchAll(PDO::FETCH_ASSOC); }
public function getRegisteredModel($name) { $model = ArrayHelper::getValue($this->allModels, $name); if ($model == null) { throw new LookupError(sprintf("Model '%s' not registered.", $name)); } return $model; }
/** * Model constructor. * * @param array $kwargs the kwargs is an associative array of configurations passed to the model, * this configurations are all optional. * * The following are valid configurations: * - db - the database connection to use * - config - to */ public function __construct($kwargs = []) { $this->constructorArgs = $kwargs; $this->init(); if ($kwargs) { $fields = $this->meta->getConcreteFields(); } else { $fields = $this->meta->getFields(); } /** @var $field Field */ foreach ($fields as $name => $field) { $val = null; $isRelated = false; if ($kwargs) { if ($field instanceof RelatedField) { //todo $isRelated = true; } else { $val = ArrayHelper::getValue($kwargs, $field->getAttrName(), $field->getDefault()); } } else { $val = $field->getDefault(); } if ($isRelated) { //todo } else { $this->{$field->getAttrName()} = $val; } } }
public function __construct($config = []) { // max_length=254 to be compliant with RFCs 3696 and 5321 $config['maxLength'] = ArrayHelper::getValue($config, 'maxLength', 254); parent::__construct($config); }
/** * @dataProvider providerGetArraysValue * * @param $array * @param $key * @param $expectedValue * @param $default * * @since 1.1.0 * * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**> */ public function testGetValue($array, $key, $expectedValue, $default) { $value = ArrayHelper::getValue($array, $key, $default); $this->assertEquals($expectedValue, $value); }
public function getFieldByName($name) { if (ArrayHelper::hasKey($this->fields, $name)) { return ArrayHelper::getValue($this->fields, $name); } throw new ValueError(sprintf('No field called [ %s ] on model [ %s ]', $name, $this->name)); }