/** * @return array */ public function toArray() { $arr = parent::toArray(); $metadata = $this->getMetadata(); if ($metadata) { $arr["metadata"] = $metadata; } return $arr; }
/** * @return array */ public function toArray() { $arr = parent::toArray(); if (array_key_exists("creditor", $arr)) { unset($arr["creditor"]); } if ($this->getCreditor() instanceof Creditor) { $arr["links"]["creditor"] = $this->getCreditor()->getId(); } return $arr; }
/** * @return array */ public function toArray() { $arr = parent::toArray(); if (array_key_exists("customer", $arr)) { unset($arr["customer"]); } if ($this->getCustomer() instanceof Customer) { $arr["links"]["customer"] = $this->getCustomer()->getId(); } if (array_key_exists("mandates", $arr)) { unset($arr["mandates"]); } return $arr; }
/** * A shorthand getter of the model variables. * * If the variable is missing, and error_reporting is turned off (by prepending the call * with the "@" operator) then the variable is treated as NULL. Otherwise a compilation * error is raised * * @return mixed */ function __get($name) { Assert::isScalar($name); if (array_key_exists($name, $this->model->toArray())) { return $this->model[$name]; } else { if (!error_reporting()) { $this->model[$name] = null; return null; } else { Assert::isUnreachable('unknown model variable %s expected within %s view', $name, $this->viewName); } } }
/** * @return array */ public function toArray() { $arr = parent::toArray(); if (array_key_exists("customerBankAccount", $arr)) { unset($arr["customerBankAccount"]); } if ($this->getCustomerBankAccount() instanceof CustomerBankAccount) { $arr["links"]["customer_bank_account"] = $this->getCustomerBankAccount()->getId(); } if (array_key_exists("creditor", $arr)) { unset($arr["creditor"]); } if ($this->getCreditor()) { $arr["links"]["creditor"] = $this->getCreditor()->getId(); } return $arr; }
/** * @param Model $user * @param string $realm */ static function updateUser($user, $realm = 'admin') { if (!session_id()) { session_start(); } $app_id = Kennel::getSetting('application', 'id'); $_SESSION["{$app_id}-{$realm}"] = $user->toArray(); self::$user[$realm] = $user; }
/** * Extract and escape all columns and values from the * model & return an array containing both strings. * * @param Model $model * @return string[] */ protected static function insertables(Model $model) { $columns = $values = []; foreach ($model->toArray() as $column => $value) { if (self::fillable($model, $column)) { $columns[] = '`' . $column . '`'; $values[] = static::$db->quote($value); } } return [implode(',', $columns), implode(',', $values)]; }
/** * Loads an item partial * @param Model $item * @return string */ private function loadItemPartial($item, $extraData = false) { // Convert our item data to a html-safe json object $data = []; foreach ($item->toArray() as $key => $value) { // If the item is json, convert it to an array and filter empty values if (is_string($value)) { $jsonArray = json_decode($value, true); if (json_last_error() == JSON_ERROR_NONE && is_array($jsonArray)) { $value = array_filter($jsonArray); } } $data[$key] = $value; } if ($extraData) { foreach ($extraData as $key => $value) { if (array_key_exists($key, $data)) { continue; } $data[$key] = $value; } } $this->vars['modelData'] = htmlspecialchars(json_encode($data)); $partialPath = isset($this->config->default) ? 'item' : $this->config->partial; $loader = new Twig_Loader_Array(['item' => $this->makePartial($partialPath, ['item' => $item])]); $twig = new Twig_Environment($loader); return $this->makePartial('input', ['item' => $item]) . $twig->render('item', $item->toArray()); }
public function toArray($element = null) { $result = parent::toArray($element); $result['fullPath'] = $this->getFullPath(); $result['hasClass'] = !!$this->getClass(); return $result; }
public function toArray() { $arr = parent::toArray(); if (array_key_exists("mandate", $arr)) { unset($arr["mandate"]); } if ($this->getMandate()) { $arr["links"]["mandate"] = $this->getMandate()->getId(); } return $arr; }
public function toArray() { return array_merge(parent::toArray(), ['logo' => route('api.payment.logo', $this)]); }
/** * calls the toArray method of models and returns the resulting array * * @param Model $model * @return void * @author Craig Ulliott */ function modelToArray(Model $model) { return $model->toArray(); }
/** * @param Model $model * @return Model|null * @throws Exception */ public function replace(Model $model) { $rtn = null; $data = $model->toArray(); $modified = $model->getModified(); $cols = []; $values = []; $params = []; foreach ($modified as $key) { $cols[] = $key; $values[] = ':' . $key; $params[':' . $key] = $data[$key]; } if (count($cols)) { $cols = '`' . implode('`, `', $cols) . '`'; $vals = implode(', ', $values); $query = "REPLACE INTO `{$this->table}` ({$cols}) VALUES ({$vals});"; $stmt = $this->connection->prepare($query); if ($stmt->execute($params)) { $modelId = !empty($data[$this->key]) ? $data[$this->key] : $this->connection->lastInsertId(); $this->cacheSet($data[$this->key], null); $rtn = $this->getByPrimaryKey($modelId, 'write'); $this->cacheSet($modelId, $rtn); } } return $rtn; }
public function toArray() { $arr = parent::toArray(); if (array_key_exists("bankAccounts", $arr)) { unset($arr["bankAccounts"]); } return $arr; }
public function toArray() { return array_merge(parent::toArray(), ['returnable' => $this->returnable]); }
/** * Convert result to domain model * * @param Model $result * @return array|Entity */ public function toDomainModel($result) { return $result ? $result->toArray() : $result; }