本文整理汇总了PHP中Oro\Bundle\EntityConfigBundle\Config\Config::has方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::has方法的具体用法?PHP Config::has怎么用?PHP Config::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\EntityConfigBundle\Config\Config
的用法示例。
在下文中一共展示了Config::has方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testValueConfig
public function testValueConfig()
{
$config = new Config(new EntityConfigId('testScope', 'testClass'));
$values = array('firstKey' => 'firstValue', 'secondKey' => 'secondValue', 'thirdKey' => 3, 'fourthKey' => new \stdClass(), 'falseKey' => false, 'nullKey' => null);
$config->setValues($values);
$this->assertEquals($values, $config->all());
$this->assertEquals(array('firstKey' => 'firstValue'), $config->all(function ($value) {
return $value == 'firstValue';
}));
$this->assertEquals('firstValue', $config->get('firstKey'));
$this->assertEquals('secondValue', $config->get('secondKey'));
$this->assertTrue($config->is('secondKey'));
$this->assertTrue($config->in('thirdKey', ['3']));
$this->assertFalse($config->in('thirdKey', ['3'], true));
$this->assertTrue($config->in('thirdKey', [3]));
$this->assertTrue($config->in('thirdKey', [3], true));
$this->assertFalse($config->in('thirdKey', [100]));
$this->assertTrue($config->has('secondKey'));
$this->assertFalse($config->has('nonExistKey'));
$this->assertTrue($config->has('falseKey'));
$this->assertTrue($config->has('nullKey'));
$this->assertNull($config->get('nonExistKey'));
$this->assertFalse($config->get('falseKey'));
$this->assertNull($config->get('nullKey'));
$this->assertEquals($config, unserialize(serialize($config)));
$config->set('secondKey', 'secondValue2');
$this->assertEquals('secondValue2', $config->get('secondKey'));
$this->assertEquals(112233, $config->get('nonExistKey', false, 112233));
$this->assertEquals('default', $config->get('nonExistKey', false, 'default'));
$this->assertEquals([], $config->get('nonExistKey', false, []));
$this->setExpectedException('Oro\\Bundle\\EntityConfigBundle\\Exception\\RuntimeException');
$config->get('nonExistKey', true);
}
示例2: testConfigHas
public function testConfigHas()
{
$config = new Config(new EntityConfigId('test', 'Entity1'), ['attr' => 'val', 'null_attr' => null]);
self::assertBenchmark(__METHOD__, 0.05, function () use($config) {
$config->has('attr');
$config->has('null_attr');
$config->has('undefined_attr');
});
}
示例3: testValueConfig
public function testValueConfig()
{
$values = array('firstKey' => 'firstValue', 'secondKey' => 'secondValue', 'fourthKey' => new \stdClass());
$this->config->setValues($values);
$this->assertEquals($values, $this->config->all());
$this->assertEquals(array('firstKey' => 'firstValue'), $this->config->all(function ($value) {
return $value == 'firstValue';
}));
$this->assertEquals('firstValue', $this->config->get('firstKey'));
$this->assertEquals('secondValue', $this->config->get('secondKey'));
$this->assertEquals(true, $this->config->is('secondKey'));
$this->assertEquals(true, $this->config->has('secondKey'));
$this->assertEquals(false, $this->config->has('thirdKey'));
$this->assertEquals(null, $this->config->get('thirdKey'));
$this->assertEquals($this->config, unserialize(serialize($this->config)));
$this->config->set('secondKey', 'secondValue2');
$this->assertEquals('secondValue2', $this->config->get('secondKey'));
$this->setExpectedException('Oro\\Bundle\\EntityConfigBundle\\Exception\\RuntimeException');
$this->config->get('thirdKey', true);
}
示例4: isApplicable
/**
* @param Config $entityConfig
* @param string $relationKey
* @return bool
*/
protected function isApplicable($entityConfig, $relationKey)
{
return $entityConfig->has('relation') && (!isset($entityConfig->get('relation')[$relationKey]) || $entityConfig->get('relation')[$relationKey]['assign'] === false);
}