protected function _createToken($username)
    {
        if (isset($this->_person)) {
            return;
        }

        $api = $this->_getApi();

        //if there's no api or the token are invalid then don't create
        //session
        if (!$api || !$api->getUser()->id) {
            return;
        }

        if ($token = $api->getToken()) {
            $person = AnService::get('repos:people.person')->find(array('username' => $username));
            $user = $api->getUser();
            $session = AnService::get('repos:connect.session')
            ->findOrAddNew(array(
                'profileId' => $user->id, 
                'api' => $api->getName()
            ));

            $session->setData(array(
                'component' => 'com_connect',
                'owner' => $person,
            ))->setToken($token);

            $session->save();

            $this->_person = $person;
            $this->_api = $api;
        }
    }
protected function _createToken($username)
    {
        if (isset($this->_person)) {
            return;
        }

        $api = $this->_getApi();

        //if there's no api or the token are invalid then don't create
        //session
        if (!$api || !$api->getUser()->id) {
            return;
        }

        if ($token = $api->getToken()) {
            $person = AnService::get('repos:people.person')->find(array('username' => $username));
            $user = $api->getUser();
            $session = AnService::get('repos:connect.session')
            ->findOrAddNew(array(
                'profileId' => $user->id, 
                'api' => $api->getName()
            ));

            $session->setData(array(
                'component' => 'com_connect',
                'owner' => $person,
            ))->setToken($token);

            $session->save();

            $this->_person = $person;
            $this->_api = $api;
        }
    }
protected function _createToken ( $ username ) { if ( isset ( $ this -> _person ) ) { return ; } $ api = $ this -> _getApi ( ) ; //if there's no api or the token are invalid then don't create //session if ( ! $ api || ! $ api -> getUser ( ) -> id ) { return ; } if ( $ token = $ api -> getToken ( ) ) { $ person = AnService :: get ( 'repos:people.person' ) -> find ( array ( 'username' => $ username ) ) ; $ user = $ api -> getUser ( ) ; $ session = AnService :: get ( 'repos:connect.session' ) -> findOrAddNew ( array ( 'profileId' => $ user -> id , 'api' => $ api -> getName ( ) ) ) ; $ session -> setData ( array ( 'component' => 'com_connect' , 'owner' => $ person , ) ) -> setToken ( $ token ) ; $ session -> save ( ) ; $ this -> _person = $ person ; $ this -> _api = $ api ; } }
Creates a connect token.
Creates a connect token .