__call() 공개 메소드

In this case we are attempting to convert camel case formatted methods into underscore formatted methods. This allows us to call ORM methods using camel case and remain backwards compatible.
public __call ( string $name, array $arguments ) : ORM
$name string
$arguments array
리턴 ORM
예제 #1
0
파일: page.php 프로젝트: nergal/2mio
 public function __call($method, array $args)
 {
     if ($method != 'loaded' and $this->loaded()) {
         $exploded = explode('_', strtolower($method));
         if (count($exploded) == 3 and $exploded[2] == 'count') {
             $type = $action = NULL;
             if (in_array($exploded[0], array('increment', 'decrement'))) {
                 $action = $exploded[0];
             }
             if (in_array($exploded[1], array('views', 'comments'))) {
                 $type = $exploded[1];
             }
             if ($type !== NULL and $action !== NULL) {
                 $key = array('count', $type, $this->id, date('Ymd'));
                 $key = implode('_', $key);
                 $default = parent::__get($type . '_count');
                 $result = Cache::instance('memcache')->{$action}($key, 1, $default);
                 return $result;
             }
         }
     }
     return parent::__call($method, $args);
 }