Phalcon\Di::getDefault PHP Method

getDefault() public static method

public static getDefault ( )
    public static function getDefault()
    {
        return self::$di;
    }

Usage Example

Example #1
1
 public function addComment($data)
 {
     /** @var myModel $this */
     $comment = new Comments();
     $comment->content = $data['content'];
     $comment->commentable_id = $this->id;
     $comment->commentable_type = get_class($this);
     //        $comment->user_id = $this->getDI()->getShared('session')->get('auth')['id'];//获得当前登录对象的id
     $user = \Phalcon\Di::getDefault()->get('auth');
     $comment->user_id = $user->id;
     //获得当前登录对象的id
     //        dd($comment);
     $comment->save();
     /** @var myModel $this */
     if (method_exists($this, 'increaseCount')) {
         $this->increaseCount('commentCount');
     } else {
         $this->save();
         //更新时间
     }
     if (is_a($this, 'Tags')) {
         $meta = $this->getTagmetaOrNew();
         $meta->save();
     }
     return $this;
 }
All Usage Examples Of Phalcon\Di::getDefault