本文整理汇总了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);
}