gb_cfilter::apply PHP Method

apply() static public method

Apply filters for $tag on $value
static public apply ( $tag, $value )
    static function apply($tag, $value)
    {
        $vargs = func_get_args();
        $tag = array_shift($vargs);
        if (!isset(self::$filters[$tag])) {
            return $value;
        }
        $a = self::$filters[$tag];
        if ($a === null) {
            return $value;
        }
        ksort($a, SORT_NUMERIC);
        foreach ($a as $funcs) {
            foreach ($funcs as $func) {
                $value = call_user_func_array($func, $vargs);
                $vargs[0] = $value;
            }
        }
        return $vargs[0];
    }

Usage Example

コード例 #1
0
ファイル: save-post.php プロジェクト: rsms/gitblog
             $v = $post->{$k};
             if ($v instanceof GBDateTime || $v instanceof GBAuthor) {
                 $v = strval($v);
             }
             $modified_state[$k] = $v;
         }
     }
 }
 # post-process checks before saving
 if ($modified_state) {
     $post->modified = new GBDateTime();
     if (!$post->title && !$post->slug) {
         throw new UnexpectedValueException('Both title and slug can not both be empty. Please choose a title for this post.');
     }
     if (!$post->slug) {
         $post->slug = gb_cfilter::apply('sanitize-title', $post->title);
     } elseif ($created && !$post->title) {
         $post->title = ucfirst($post->slug);
     }
 }
 # set newborn properties
 if ($created) {
     if (!$post->mimeType) {
         $post->mimeType = 'text/html';
         gb::log('did force html');
     } else {
         gb::log('mime type is %s', $post->mimeType);
     }
     if (!$post->published) {
         $post->published = $post->modified;
     }
All Usage Examples Of gb_cfilter::apply
gb_cfilter