BlogHelper::getCategory PHP Method

getCategory() public method

記事が属するカテゴリ名を取得する
public getCategory ( array $post, array $options = [] ) : string
$post array 記事データ
$options array オプション(初期値 : array()) - `link` : リンクをつけるかどうか(初期値 : true) ※ その他のオプションは、`link`オプションが`true`の場合に 生成されるa要素の属性設定となる。(HtmlHelper::link() を参照)
return string カテゴリ名
    public function getCategory($post, $options = array())
    {
        if (!empty($post['BlogCategory']['name'])) {
            $options = am(array('link' => true), $options);
            $link = false;
            if ($options['link']) {
                $link = true;
            }
            unset($options['link']);
            if ($link) {
                if (!isset($this->Html)) {
                    App::uses('HtmlHelper', 'View/Helper');
                    $this->Html = new HtmlHelper($this->_View);
                }
                return $this->Html->link($post['BlogCategory']['title'], $this->getCategoryUrl($post['BlogCategory']['id'], $options), $options, null, false);
            } else {
                return $post['BlogCategory']['title'];
            }
        } else {
            return '';
        }
    }