本文整理汇总了PHP中JMS\Serializer\SerializerBuilder::addMetadataDir方法的典型用法代码示例。如果您正苦于以下问题:PHP SerializerBuilder::addMetadataDir方法的具体用法?PHP SerializerBuilder::addMetadataDir怎么用?PHP SerializerBuilder::addMetadataDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMS\Serializer\SerializerBuilder
的用法示例。
在下文中一共展示了SerializerBuilder::addMetadataDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
public function build()
{
$this->setObjectManager($this->createEntityManager());
$this->serializerBuilder = BreezeSerializerBuilder::create($this->getObjectManager());
$this->validatorBuilder = new ValidatorBuilder();
if ($this->annotationsEnabled) {
$this->validatorBuilder->enableAnnotationMapping();
}
foreach ($this->mappings as $mapping) {
if (isset($mapping['serializer'])) {
$this->serializerBuilder->addMetadataDir($mapping['serializer']);
}
if (isset($mapping['validation'])) {
if ($mapping['type'] == 'xml') {
$this->validatorBuilder->addXmlMapping($mapping['validation']);
} else {
if ($mapping['type'] == 'yaml') {
$this->validatorBuilder->addYamlMapping($mapping['validation']);
}
}
// else if ($mapping['type'] == 'annotation') {
// $this->validatorBuilder->enableAnnotationMapping();
// }
}
}
$serializer = $this->serializerBuilder->build();
$this->setSerializer($serializer);
$validator = $this->validatorBuilder->getValidator();
$this->setValidator($validator);
}
示例2: __construct
/**
* @param array $options
*/
public function __construct($options)
{
$this->options = $options;
$builder = new SerializerBuilder();
$this->serializer = $builder->addMetadataDir(realpath(__DIR__ . '/../Resources/serializer'))->build();
}
示例3: registerXApiMetadata
/**
* Registers serialization metadata for the xAPI models on a SerializerBuilder.
*
* @param SerializerBuilder $builder The SerializerBuilder
*/
public static function registerXApiMetadata(SerializerBuilder $builder)
{
$builder->addMetadataDir(static::getMetadataDirectory(), 'Xabbuh\\XApi\\Model');
}
示例4: setUp
public function setUp()
{
$this->storeKey = array('api_key' => '0e54680857cc2874d9f3874364d786c3', 'password' => '8ad3f0ee9cec0c559046f273dd22350c', 'secret' => '139bfc86c90a8893e0bb97560a5e0e4a', 'domain' => 'symfony-shopify-bundle.myshopify.com');
$builder = new SerializerBuilder();
$this->serializer = $builder->addMetadataDir(realpath(__DIR__ . '/../Resources/serializer'))->build();
}