作者:muramoy
项目:kotor
/**
* Modelのエラーメッセージを取得
* @return array
*/
public function getErrorMessages()
{
foreach ($this->model->getMessages() as $msgs) {
$errMsgs[] = $msgs->getMessage();
}
return $errMsgs;
}
作者:adiachenk
项目:phstar
public function showModelErrors(Model $model, Form $form)
{
foreach ($model->getMessages() as $message) {
$fieldName = $message->getField();
$form->addModelError($fieldName, $message->getMessage());
}
}
作者:anderson-slomp
项目:wsGerPro
/**
* Recebe um model e une as excessões para retornar em texto
*
* @param \Phalcon\Mvc\Model $model
* @return string
*/
public static function createModelErrorMessages(\Phalcon\Mvc\Model $model)
{
$excepts = [];
foreach ($model->getMessages() as $message) {
$excepts[] = $message;
}
return implode("\n", $excepts);
}
作者:fu-ta
项目:meelier_
/**
* 数据库操作异常
* @param \Phalcon\Mvc\Model $model
* @return bool
*/
public function databaseErrorLog($model)
{
$error = '';
foreach ($model->getMessages() as $msg) {
$error .= $msg . ',';
}
$this->di->get('logger')->error('数据库异常, GET:' . json_encode($_GET) . ', POST:' . json_encode($_POST) . ', error: ' . $error);
return false;
}
作者:fu-ta
项目:meelier_
/**
* 数据库操作异常
* @param \Phalcon\Mvc\Model $model
*/
public function logDatabaseError($model)
{
if ($this->di->offsetExists('logger') == false) {
return;
}
$error = '';
foreach ($model->getMessages() as $msg) {
$error .= $msg . ',';
}
$this->di->get('logger')->error('数据库异常, GET:' . json_encode($_GET) . ', POST: ' . json_encode($_POST) . ', error: ' . $error);
}
作者:akashkumardc
项目:phalco
public static function findFirst($parameters = NULL, $hostType = NULL)
{
$class = get_called_class();
$object = new $class();
BaseModel::$tableName = $object->getSource();
BaseModel::$hostType = $hostType;
return parent::findFirst($parameters);
}
作者:kp-favorit
项目:bitfalls_util
/**
* @param bool $bAsString
* @return \Phalcon\Mvc\Model\MessageInterface[]|string
*/
public function getMessages($bAsString = false)
{
if (!$bAsString) {
return parent::getMessages();
} else {
return implode(', ', parent::getMessages());
}
}
作者:frangeri
项目:bille
/**
* Initializer
*
* @param \Phalcon\Config $config Phalcon config
* @return bool
*/
public static function me(\Phalcon\Config $config)
{
// validate biller in config
if (!isset($config['biller'])) {
throw new \Exception('Entry for "biller" not found on config');
}
// validate stripe key
if (!isset($config['biller']['key'])) {
throw new \Exception('Stripe key not found on config');
}
// setup the stripe key
\Stripe\Stripe::setApiKey($config['biller']['key']);
// throw exceptions for customer, subscriptions models
\Phalcon\Mvc\Model::setup(['exceptionOnFailedSave' => true]);
}
作者:huoyb
项目:standar
public static function buildFormFromModel(\Phalcon\Mvc\Model $model, array $extraFields = null)
{
if ($model->id) {
$form = new Form($model);
} else {
$form = new Form();
}
$fields = [];
foreach ($model->columnMap() as $column) {
$metaDataTypes = $model->getModelsMetaData()->getDataTypes($model);
if (!in_array($column, ['created_at', 'updated_at', 'id', 'password', 'remember_token'])) {
if ($metaDataTypes[$column] != 6) {
$form->add(new Text($column));
} else {
$form->add(new TextArea($column));
}
$fields[] = $column;
}
}
if (null != $extraFields) {
foreach ($extraFields as $column) {
if (in_array($column, $model->columnMap())) {
continue;
}
$form->add(new Text($column));
$fields[] = $column;
}
}
$form->fields = $fields;
if ($model->id) {
$form->add(new Submit('修改'));
} else {
$form->add(new Submit('增加'));
}
return $form;
}
作者:nbtetreaul
项目:ig
public function delete()
{
foreach ($this->IgoListeValeur as $liste) {
$liste->delete();
}
return parent::delete();
}
作者:soutone
项目:api-desconect
/**
* Replace/translate default messages generated by the ORM.
*
* @return array
*/
public function getMessages()
{
foreach (parent::getMessages() as $message) {
switch ($message->getType()) {
case 'PresenceOf':
$message->setMessage('The field ' . $message->getField() . ' is required');
break;
case 'Uniqueness':
$message->setMessage('The field ' . $message->getField() . ' must be unique');
break;
case 'Email':
$message->setMessage('The field ' . $message->getField() . ' must contain a valid email');
break;
case 'Url':
$message->setMessage('The field ' . $message->getField() . ' must contain a valid url');
break;
case 'InclusionIn':
$message->setMessage('The field ' . $message->getField() . ' must contain a value in [' . implode(',', $message->getDomain()) . ']');
break;
case 'DateValidator':
$message->setMessage('The field ' . $message->getField() . ' must contain a valid date.');
break;
case 'TimestampValidator':
$message->setMessage('The field ' . $message->getField() . ' must contain a valid timestamps.');
break;
}
}
return parent::getMessages();
}
作者:panlaten
项目:swila
public static function __callStatic($name, $parameters = null)
{
if (0 === strpos($name, 'has')) {
return static::hasColumnValue(Str::convertSnake(substr($name, 3)), $parameters[0]);
}
return parent::__callStatic($name, $parameters);
}
作者:skulla
项目:area5
public function __set($property, $value)
{
if (is_object($property) || is_array($property)) {
return parent::__set($property, $value);
}
$this->_dataAccess[$property] = $value;
}
作者:abc2001
项目:phalcon_mod
public function __set($fieldName, $value)
{
// Check if the property is public
try {
$R = new \ReflectionClass($this);
$property = $R->getProperty($fieldName);
} catch (\ReflectionException $e) {
// Property doesn't exist, call the stupid parent
return parent::__set($fieldName, $value);
}
if ($property->isPublic()) {
// Again, call your parents
return parent::__set($fieldName, $value);
} else {
// Property exists, and it's private / protected
try {
// Maybe there is a setter for this one?
$nameArr = explode('_', $fieldName);
$methodName = 'set';
foreach ($nameArr as $vv) {
$methodName .= ucwords($vv);
}
$method = $R->getMethod($methodName);
// Okay, no exception, let's call it
return $this->{$methodName}($value);
} catch (\ReflectionException $up) {
// Just let it go through
throw $up;
}
}
}
作者:nbtetreaul
项目:ig
public function delete()
{
foreach ($this->IgoGeometrie as $geometrie) {
$geometrie->delete();
}
return parent::delete();
}
作者:phalco
项目:foru
/**
* Caches models data in memory
*
* @param mixed $parameters
* @return $this
*/
public static function findFirst($parameters = null)
{
// Create an unique key based on the parameters
if ($key = self::createKey($parameters)) {
$parameters['cache'] = ['key' => $key];
}
return parent::findFirst($parameters);
}
作者:nbtetreaul
项目:ig
public function save($saveMapFile = true, $data = NULL, $whiteList = NULL)
{
$retour = parent::save($data, $whiteList);
if ($saveMapFile && $this->IgoCouche->IgoGeometrie->acces == "L") {
$this->IgoCouche->save();
}
return $retour;
}
作者:hongke
项目:Blo
/**
* 重写validate方法
* @param unknown $validator
* @return boolean
*/
protected function validate($validator)
{
parent::validate($validator);
if ($this->validationHasFailed() == true) {
return false;
}
return true;
}
作者:aforwar
项目:phpwe
public function save($data = null, $whitelist = null)
{
$results = parent::save($data, $whitelist);
// Update order of child entities
if (isset($data['childSortOrder'])) {
$this->updateChildSortOrder($data['childSortOrder']);
}
return $results;
}
作者:romainroufas
项目:bilionairebikersclu
public static function findFirstAsArray($id, $pullDocuments = false)
{
$p = parent::findFirst($id);
$p = $p->toArray();
if ($pullDocuments) {
$p['documents'] = Documents::findByProjectId($id);
}
return $p;
}