예제 #1
0
 public static function __callStatic($func, array $args)
 {
     if (empty($args)) {
         return self::$app->get($func);
     }
     array_unshift($args, $func);
     return call_user_func_array(array(self::$app, 'get'), $args);
 }
예제 #2
0
파일: common.php 프로젝트: wells5609/wp-app
/**
 * Returns or sets a DI value.
 * 
 * @param string $key
 * @param mixed $value [Optional]
 * @param boolean $shared [Optional] Default = false
 * 
 * @return mixed|void
 */
function di($key, $value = null, $shared = false)
{
    if ($value === null) {
        return WordPress\App::instance()->get($key);
    } else {
        WordPress\App::instance()->set($key, $value, $shared);
    }
}
예제 #3
0
파일: post.php 프로젝트: wells5609/wp-app
/**
 * Returns a \WordPress\Model\Post instance for the given post.
 * 
 * @param null|int|WP_Post $post [Optional] Post ID or object, or null to use global.
 * @return \WordPress\Model\Post
 */
function get_custom_post($post = null)
{
    if (null === $post) {
        return WordPress\App::instance()->getPost();
    } else {
        if (!$post instanceof WP_Post) {
            $post = get_post($post);
        }
    }
    return WordPress\App::instance()->get('modelManager')->getInstance('post', $post);
}
예제 #4
0
파일: model.php 프로젝트: wells5609/wp-app
/**
 * Returns an instance of a model.
 * 
 * @param string $name
 * @param mixed $data
 * @return \WordPress\Model\ModelInterface
 */
function model_instance($name, $data)
{
    return WordPress\App::instance()->get('modelManager')->getInstance($name, $data);
}