本文整理汇总了PHP中Zend\Stdlib\Hydrator\ClassMethods::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMethods::setOptions方法的具体用法?PHP ClassMethods::setOptions怎么用?PHP ClassMethods::setOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Stdlib\Hydrator\ClassMethods
的用法示例。
在下文中一共展示了ClassMethods::setOptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setOptions
/**
* @param array|\Traversable $options
*
* @return Hydrator\ClassMethods
* @throws \Zend\Stdlib\Exception\InvalidArgumentException
*/
public function setOptions($options)
{
parent::setOptions($options);
if (array_key_exists('excluded_methods', $options) && is_array($options['excluded_methods'])) {
$filters = [];
foreach ($options['excluded_methods'] as $methodName) {
$methodName = (string) $methodName;
$filters[] = new Hydrator\Filter\MethodMatchFilter($methodName);
}
$this->getFilter()->addFilter('excludedMethods', new Hydrator\Filter\FilterComposite([], $filters), Hydrator\Filter\FilterComposite::CONDITION_AND);
}
return $this;
}
示例2: testHydratorClassMethodsOptions
public function testHydratorClassMethodsOptions()
{
$hydrator = new ClassMethods();
$this->assertTrue($hydrator->getUnderscoreSeparatedKeys());
$hydrator->setOptions(array('underscoreSeparatedKeys' => false));
$this->assertFalse($hydrator->getUnderscoreSeparatedKeys());
$hydrator->setUnderscoreSeparatedKeys(true);
$this->assertTrue($hydrator->getUnderscoreSeparatedKeys());
}