本文整理匯總了PHP中Symfony\Component\Serializer\Serializer::__construct方法的典型用法代碼示例。如果您正苦於以下問題:PHP Serializer::__construct方法的具體用法?PHP Serializer::__construct怎麽用?PHP Serializer::__construct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Serializer\Serializer
的用法示例。
在下文中一共展示了Serializer::__construct方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Constructor
*
* @param EntityManager $entityManager
* @param array $normalizers
* @param array $encoders
*/
public function __construct(EntityManager $entityManager, array $normalizers = array(), array $encoders = array())
{
$this->entityManager = $entityManager;
parent::__construct($normalizers, $encoders);
foreach ($this->normalizers as $normalizer) {
if ($normalizer instanceof DoctrineEntitySerializerAwareInterface) {
$normalizer->setSerializer($this);
}
}
}
示例2: __construct
public function __construct(array $transformers = array(), array $encoders = array())
{
foreach ($transformers as $transformer) {
if (!$transformer instanceof SerializedClassInterface) {
$message = sprintf('Transformer %s must implement %s', get_class($transformer), SerializedClassInterface::CLASS_NAME);
throw new UnexpectedValueException($message);
}
}
parent::__construct($transformers, $encoders);
}
示例3: __construct
/**
* @param EncoderInterface[] $encoders
*/
public function __construct(array $encoders = [])
{
$normalizers = [new ResultSetNormalizer(), new ItemNormalizer(), new StatsNormalizer()];
parent::__construct($normalizers, $encoders);
}
示例4: __construct
public function __construct(array $normalizers = array(), array $encoders = array())
{
$normalizers = array_merge($normalizers, array(new EntityNormalizer()));
$encoders = array_merge($encoders, array(new \Symfony\Component\Serializer\Encoder\JsonEncoder(), new \Symfony\Component\Serializer\Encoder\XmlEncoder(), new YamlEncoder()));
return parent::__construct($normalizers, $encoders);
}