public function __call($function, $args) { switch (true) { case preg_match('/^fetchBy[A-Z]/', $function): $field = preg_replace('/^fetchBy/', '', $function); $field = Monday_Model::functionToField($field); return $this->fetchSpecificField($field, $args); break; } throw new Exception('Incorrect function call'); }
public static function service($class, $namespace = null) { $class = ucfirst($class); // Generella services finns inte, men ibland vill vi cacha $className = "Service_" . Monday_Model::fieldToFunction($class); $service = self::load($className, $namespace); return $service; }
public function delete(Monday_Model $model) { $table = $this->getTable(); $info = $table->info(); $primaryGetter = 'get' . Monday_Model::fieldToFunction(array_pop($info['primary'])); $row = $table->find($model->{$primaryGetter}())->current(); if ($row) { $row->delete(); } }