Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setAuth example
$identity
=
$auth
->
getIdentity
(
)
;
$userID
=
(int)
$identity
->id;
$request
=
$this
->
Request
(
)
;
$widgetId
=
(int)
$request
->
getParam
(
'id'
)
;
$column
=
$request
->
getParam
(
'column'
)
;
$position
=
$request
->
getParam
(
'position'
)
;
$data
=
$request
->
getParam
(
'data',
[
]
)
;
$model
=
new
View
(
)
;
$model
->
setWidget
(
$this
->
get
(
ModelManager::
class
)
->
find
(
Widget::
class
,
$widgetId
)
)
;
$model
->
setAuth
(
$this
->
get
(
ModelManager::
class
)
->
find
(
User::
class
,
$userID
)
)
;
$model
->
setColumn
(
$column
)
;
$model
->
setPosition
(
$position
)
;
$model
->
setData
(
$data
)
;
$this
->
get
(
ModelManager::
class
)
->
persist
(
$model
)
;
$this
->
get
(
ModelManager::
class
)
->
flush
(
)
;
$viewId
=
$model
->
getId
(
)
;
$this
->
View
(
)
->
assign
(
[
'success' => !
empty
(
$viewId
)
, 'viewId' =>
$viewId
]
)
;
}
elseif
(
is_string
(
$uri
)
)
{
$uri
= Zend_Uri::
factory
(
$uri
)
;
}
if
(
!
$uri
instanceof Zend_Uri_Http
)
{
/** @see Zend_Http_Client_Exception */
throw
new
Zend_Http_Client_Exception
(
'Passed parameter is not a valid HTTP URI.'
)
;
}
// Set auth if username and password has been specified in the uri
if
(
$uri
->
getUsername
(
)
&&
$uri
->
getPassword
(
)
)
{
$this
->
setAuth
(
$uri
->
getUsername
(
)
,
$uri
->
getPassword
(
)
)
;
}
// We have no ports, set the defaults
if
(
!
$uri
->
getPort
(
)
)
{
$uri
->
setPort
(
(
$uri
->
getScheme
(
)
== 'https' ? 443 : 80
)
)
;
}
$this
->uri =
$uri
;
return
$this
;
}