Skip to content

Loading…

Formatting changes #487

Closed
wants to merge 2 commits into from

2 participants

@m3zercat

Merely changed some layout of code in Field.php to make it more readable / consistent.
Also filled in some phpdoc for a function missing it.

m3zercat added some commits
@m3zercat m3zercat added missing hooks
Added the missing hooks that were present in Model:
beforeUpdate, afterUpdate, beforeInsert, afterInsert
83545d1
@m3zercat m3zercat fixed some minor layout issues in lib/Field.php c040c7a
@romaninsh
atk4 member

I have merged the cleanup part in a4a390e

@romaninsh romaninsh closed this
@m3zercat m3zercat deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 23, 2014
  1. @m3zercat

    added missing hooks

    m3zercat committed
    Added the missing hooks that were present in Model:
    beforeUpdate, afterUpdate, beforeInsert, afterInsert
Commits on Feb 27, 2014
  1. @m3zercat
Showing with 25 additions and 10 deletions.
  1. +21 −10 lib/Field.php
  2. +4 −0 lib/SQL/Model.php
View
31 lib/Field.php
@@ -471,17 +471,28 @@ function setValueList($t)
*
* @return array current value if $t=UNDEFINED
*/
- function enum($t){ return $this->listData(array_combine($t,$t)); }
- /** Binds the field to a relation (returned by join() function) */
- function from($m){
- if($m===undefined)return $this->relation;
- if(is_object($m)){
- $this->relation=$m;
- }else{
- $this->relations=$this->owner->relations[$m];
- }
- return $this;
+ function enum($t){
+ return $this->listData(array_combine($t,$t));
+ }
+
+ /**
+ * Binds the field to a relation (returned by join() function)
+ *
+ * @param Object $m the result of join() function
+ *
+ * @return self or the relation if $m is undefined
+ */
+ function from($m){
+ if($m===undefined){
+ return $this->relation;
+ }elseif(is_object($m)){
+ $this->relation=$m;
+ }else{
+ $this->relations=$this->owner->relations[$m];
}
+ return $this;
+ }
+
// what is alias?
//function alias($t=undefined){ return $this->setterGetter('alias',$t); }
View
4 lib/SQL/Model.php
@@ -605,9 +605,13 @@ function save(){
// decide, insert or modify
if($this->loaded()){
+ $this->hook('beforeUpdate');
$res=$this->modify();
+ $this->hook('afterUpdate');
}else{
+ $this->hook('beforeInsert');
$res=$this->insert();
+ $this->hook('afterInsert');
}
$res->hook('afterSave');
Something went wrong with that request. Please try again.