Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setCreatedAt example
$userId
= '6f51622eb3814c75ae0263cece27ce72';
$user
=
new
UserEntity
(
)
;
$user
->
setId
(
$userId
)
;
$user
->
setFirstName
(
'Manufacturer'
)
;
$user
->
setLastName
(
''
)
;
$user
->
setPassword
(
'password'
)
;
$user
->
setUsername
(
'user1'
)
;
$user
->
setActive
(
true
)
;
$user
->
setAdmin
(
true
)
;
$user
->
setEmail
(
'user1@shop.de'
)
;
$user
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.000+00:00'
)
)
;
$user
->
internalSetEntityData
(
'user',
new
FieldVisibility
(
[
]
)
)
;
$media1
=
new
MediaEntity
(
)
;
$media1
->
setId
(
'3e352be2d85846dd97529c0f6b544870'
)
;
$media1
->
setUser
(
$user
)
;
$media1
->
setUserId
(
$userId
)
;
$media1
->
setMimeType
(
'image/jpg'
)
;
$media1
->
setFileExtension
(
'jpg'
)
;
$media1
->
setFileSize
(
18921
)
;
$media1
->
setCreatedAt
(
new
\
DateTime
(
'2012-08-15T00:00:00.000+00:00'
)
)
;
$media1
->
setUpdatedAt
(
new
\
DateTime
(
'2017-11-21T11:25:34.000+00:00'
)
)
;
$product
->
setShippingTime
(
$data
[
'__variant_shippingtime'
]
)
;
}
elseif
(
$data
[
'__product_shippingtime'
]
)
{
$product
->
setShippingTime
(
$data
[
'__product_shippingtime'
]
)
;
}
if
(
$data
[
'__variant_releasedate'
]
)
{
$product
->
setReleaseDate
(
new
DateTime
(
$data
[
'__variant_releasedate'
]
)
)
;
}
if
(
$data
[
'__product_datum'
]
)
{
$product
->
setCreatedAt
(
new
DateTime
(
$data
[
'__product_datum'
]
)
)
;
}
if
(
$data
[
'__product_changetime'
]
)
{
$product
->
setUpdatedAt
(
new
DateTime
(
$data
[
'__product_changetime'
]
)
)
;
}
$product
->
setAdditional
(
$data
[
'__variant_additionaltext'
]
)
;
$product
->
setEan
(
$data
[
'__variant_ean'
]
)
;
$product
->
setFormattedUpdatedAt
(
$this
->
formatDate
(
$product
->
getUpdatedAt
(
)
)
)
;
$product
->
setFormattedReleaseDate
(
$this
->
formatDate
(
$product
->
getReleaseDate
(
)
)
)
;
$product
->
addAttributes
(
$this
->
parseAttributes
(
$product
->
getAttributes
(
)
)
)
;
$product
->
setCreatedAt
(
null
)
;
$product
->
setUpdatedAt
(
null
)
;
$product
->
setReleaseDate
(
null
)
;
$product
->
setPrices
(
null
)
;
$product
->
setPriceRules
(
null
)
;
$product
->
setCheapestPriceRule
(
null
)
;
$product
->
setCheapestPrice
(
null
)
;
$product
->
setCheapestUnitPrice
(
null
)
;
$product
->
setAvailableCombinations
(
null
)
;
$product
->
setFullConfiguration
(
null
)
;
$product
->
resetStates
(
)
;
public
function
hydrate
(
array
$data
)
{
$esd
=
new
Esd
(
)
;
if
(
isset
(
$data
[
'__esd_id'
]
)
)
{
$esd
->
setId
(
(int)
$data
[
'__esd_id'
]
)
;
}
if
(
isset
(
$data
[
'__esd_datum'
]
)
)
{
$esd
->
setCreatedAt
(
new
DateTime
(
$data
[
'__esd_datum'
]
)
)
;
}
if
(
isset
(
$data
[
'__esd_file'
]
)
)
{
$esd
->
setFile
(
$data
[
'__esd_file'
]
)
;
}
if
(
isset
(
$data
[
'__esd_serials'
]
)
)
{
$esd
->
setHasSerials
(
(bool)
$data
[
'__esd_serials'
]
)
;
}
if
(
isset
(
$data
[
'__esdAttribute_id'
]
)
)
{
$userId
= 'f343a3c119cf42a7841aa0ac5094908c';
$user
=
new
UserEntity
(
)
;
$user
->
setId
(
$userId
)
;
$user
->
setFirstName
(
'Manufacturer'
)
;
$user
->
setLastName
(
''
)
;
$user
->
setPassword
(
'password'
)
;
$user
->
setUsername
(
'user1'
)
;
$user
->
setActive
(
true
)
;
$user
->
setAdmin
(
true
)
;
$user
->
setEmail
(
'user1@shop.de'
)
;
$user
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.000+00:00'
)
)
;
$user
->
internalSetEntityData
(
'user',
new
FieldVisibility
(
[
]
)
)
;
$media
=
new
MediaEntity
(
)
;
$media
->
setId
(
'3e352be2d85846dd97529c0f6b544870'
)
;
$media
->
setUser
(
clone
$user
)
;
$media
->
setUserId
(
$userId
)
;
$media
->
setMimeType
(
'image/jpg'
)
;
$media
->
setFileExtension
(
'jpg'
)
;
$media
->
setFileSize
(
18921
)
;
$media
->
setCreatedAt
(
new
\
DateTime
(
'2012-08-15T00:00:00.000+00:00'
)
)
;
$media
->
setUpdatedAt
(
new
\
DateTime
(
'2017-11-21T11:25:34.000+00:00'
)
)
;
if
(
isset
(
$data
[
'__vote_points'
]
)
)
{
$struct
->
setPoints
(
(float)
$data
[
'__vote_points'
]
)
;
}
if
(
isset
(
$data
[
'__vote_comment'
]
)
)
{
$struct
->
setComment
(
$data
[
'__vote_comment'
]
)
;
}
if
(
isset
(
$data
[
'__vote_datum'
]
)
&&
$data
[
'__vote_datum'
]
!= '0000-00-00 00:00:00'
)
{
$struct
->
setCreatedAt
(
new
DateTime
(
$data
[
'__vote_datum'
]
)
)
;
}
if
(
isset
(
$data
[
'__vote_email'
]
)
)
{
$struct
->
setEmail
(
$data
[
'__vote_email'
]
)
;
}
if
(
isset
(
$data
[
'__vote_headline'
]
)
)
{
$struct
->
setHeadline
(
$data
[
'__vote_headline'
]
)
;
}
class
TestBasicStruct
extends
SerializationFixture
{
public
function
getInput
(
)
: EntityCollection|Entity
{
$media
=
new
MediaEntity
(
)
;
$media
->
setId
(
'1d23c1b015bf43fb97e89008cf42d6fe'
)
;
$media
->
setTitle
(
'Manufacturer'
)
;
$media
->
setMimeType
(
'image/png'
)
;
$media
->
setFileExtension
(
'png'
)
;
$media
->
setFileSize
(
310818
)
;
$media
->
setAlt
(
'A media object description'
)
;
$media
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.432+00:00'
)
)
;
$media
->
internalSetEntityData
(
'media',
new
FieldVisibility
(
[
]
)
)
;
return
$media
;
}
/** * @return array<string, mixed> */
protected
function
getJsonApiFixtures
(
string
$baseUrl
)
: array
{
return
[
$userId
= '6f51622eb3814c75ae0263cece27ce72';
$user
=
new
UserEntity
(
)
;
$user
->
setId
(
$userId
)
;
$user
->
setFirstName
(
'Manufacturer'
)
;
$user
->
setLastName
(
''
)
;
$user
->
setPassword
(
'password'
)
;
$user
->
setUsername
(
'user1'
)
;
$user
->
setActive
(
true
)
;
$user
->
setAdmin
(
true
)
;
$user
->
setEmail
(
'user1@shop.de'
)
;
$user
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.000+00:00'
)
)
;
$user
->
internalSetEntityData
(
'user',
new
FieldVisibility
(
[
]
)
)
;
$media
=
new
MediaEntity
(
)
;
$media
->
setId
(
'548faa1f7846436c85944f4aea792d96'
)
;
$media
->
setUserId
(
$userId
)
;
$media
->
setMimeType
(
'image/jpg'
)
;
$media
->
setFileExtension
(
'jpg'
)
;
$media
->
setFileSize
(
93889
)
;
$media
->
setTitle
(
'2'
)
;
$media
->
setCreatedAt
(
new
\
DateTime
(
'2012-08-31T00:00:00.000+00:00'
)
)
;
$media
->
setUpdatedAt
(
new
\
DateTime
(
'2017-11-21T11:25:34.000+00:00'
)
)
;
class
TestCollectionWithSelfReference
extends
SerializationFixture
{
/** * @return MediaFolderCollection|MediaFolderEntity */
public
function
getInput
(
)
: EntityCollection|Entity
{
$parent
=
new
MediaFolderEntity
(
)
;
$parent
->
setId
(
'3e352be2d85846dd97529c0f6b544870'
)
;
$parent
->
setChildCount
(
1
)
;
$parent
->
setUseParentConfiguration
(
false
)
;
$parent
->
setCreatedAt
(
new
\
DateTime
(
'2012-08-15T00:00:00.000+00:00'
)
)
;
$parent
->
setUpdatedAt
(
new
\
DateTime
(
'2017-11-21T11:25:34.000+00:00'
)
)
;
$parent
->
internalSetEntityData
(
'media_folder',
new
FieldVisibility
(
[
]
)
)
;
$child
=
new
MediaFolderEntity
(
)
;
$child
->
setId
(
'5846dd97529c0f6b5448713e352be2d8'
)
;
$child
->
setChildCount
(
1
)
;
$child
->
setUseParentConfiguration
(
true
)
;
$child
->
setParentId
(
'3e352be2d85846dd97529c0f6b544870'
)
;
$child
->
setCreatedAt
(
new
\
DateTime
(
'2012-08-15T00:00:00.000+00:00'
)
)
;
$child
->
setUpdatedAt
(
new
\
DateTime
(
'2017-11-21T11:25:34.000+00:00'
)
)
;
$child
->
internalSetEntityData
(
'media_folder',
new
FieldVisibility
(
[
]
)
)
;
$product
->
setKeywords
(
$listProduct
->
getKeywords
(
)
)
;
$product
->
setLength
(
$listProduct
->
getLength
(
)
)
;
$product
->
setLongDescription
(
$listProduct
->
getLongDescription
(
)
)
;
$product
->
setMinStock
(
$listProduct
->
getMinStock
(
)
)
;
$product
->
setReleaseDate
(
$listProduct
->
getReleaseDate
(
)
)
;
$product
->
setShippingTime
(
$listProduct
->
getShippingTime
(
)
)
;
$product
->
setShortDescription
(
$listProduct
->
getShortDescription
(
)
)
;
$product
->
setStock
(
$listProduct
->
getStock
(
)
)
;
$product
->
setWeight
(
$listProduct
->
getWeight
(
)
)
;
$product
->
setWidth
(
$listProduct
->
getWidth
(
)
)
;
$product
->
setPriceGroup
(
$listProduct
->
getPriceGroup
(
)
)
;
$product
->
setCreatedAt
(
$listProduct
->
getCreatedAt
(
)
)
;
$product
->
setUpdatedAt
(
$listProduct
->
getUpdatedAt
(
)
)
;
$product
->
setPriceRules
(
$listProduct
->
getPriceRules
(
)
)
;
$product
->
setCheapestPriceRule
(
$listProduct
->
getCheapestPriceRule
(
)
)
;
$product
->
setManufacturerNumber
(
$listProduct
->
getManufacturerNumber
(
)
)
;
$product
->
setMetaTitle
(
$listProduct
->
getMetaTitle
(
)
)
;
$product
->
setTemplate
(
$listProduct
->
getTemplate
(
)
)
;
$product
->
setHasConfigurator
(
$listProduct
->
hasConfigurator
(
)
)
;
$product
->
setSales
(
$listProduct
->
getSales
(
)
)
;
$product
->
setHasEsd
(
$listProduct
->
hasEsd
(
)
)
;
$product
->
setEsd
(
$listProduct
->
getEsd
(
)
)
;
$product
->
setIsPriceGroupActive
(
$listProduct
->
isPriceGroupActive
(
)
)
;
$userId
= '6f51622eb3814c75ae0263cece27ce72';
$user
=
new
UserEntity
(
)
;
$user
->
setId
(
$userId
)
;
$user
->
setFirstName
(
'Manufacturer'
)
;
$user
->
setLastName
(
''
)
;
$user
->
setPassword
(
'password'
)
;
$user
->
setUsername
(
'user1'
)
;
$user
->
setActive
(
true
)
;
$user
->
setAdmin
(
true
)
;
$user
->
setEmail
(
'user1@shop.de'
)
;
$user
->
setCreatedAt
(
new
\
DateTime
(
'2018-01-15T08:01:16.000+00:00'
)
)
;
$user
->
internalSetEntityData
(
'user',
new
FieldVisibility
(
[
]
)
)
;
$media
=
new
MediaEntity
(
)
;
$media
->
setId
(
'548faa1f7846436c85944f4aea792d96'
)
;
$media
->
setUserId
(
$userId
)
;
$media
->
setMimeType
(
'image/jpg'
)
;
$media
->
setFileExtension
(
'jpg'
)
;
$media
->
setFileSize
(
93889
)
;
$media
->
setTitle
(
'2'
)
;
$media
->
setCreatedAt
(
new
\
DateTime
(
'2012-08-31T00:00:00.000+00:00'
)
)
;
$media
->
setUpdatedAt
(
new
\
DateTime
(
'2017-11-21T11:25:34.000+00:00'
)
)
;