本文整理汇总了PHP中Webmozart\Expression\Expr::key方法的典型用法代码示例。如果您正苦于以下问题:PHP Expr::key方法的具体用法?PHP Expr::key怎么用?PHP Expr::key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Expression\Expr
的用法示例。
在下文中一共展示了Expr::key方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBuildExpressionWithCustomCriteria
public function testBuildExpressionWithCustomCriteria()
{
$expr1 = Expr::startsWith('abcd', AssetMapping::UUID)->orSame('local', AssetMapping::SERVER_NAME)->orX(Expr::same('/path', AssetMapping::GLOB)->andSame('css', AssetMapping::SERVER_PATH));
$expr2 = Expr::same(BindingState::ENABLED, BindingDescriptor::STATE)->andSame(DiscoveryUrlGenerator::BINDING_TYPE, BindingDescriptor::TYPE_NAME)->andEndsWith('{,/**/*}', BindingDescriptor::QUERY)->andX(Expr::startsWith('abcd', BindingDescriptor::UUID)->orKey(BindingDescriptor::PARAMETER_VALUES, Expr::key(DiscoveryUrlGenerator::SERVER_PARAMETER, Expr::same('local')))->orX(Expr::same('/path{,/**/*}', BindingDescriptor::QUERY)->andKey(BindingDescriptor::PARAMETER_VALUES, Expr::key(DiscoveryUrlGenerator::PATH_PARAMETER, Expr::same('css')))));
$this->assertEquals($expr2, $this->builder->buildExpression($expr1));
}
示例2: orKey
public function orKey($keyName, Expression $expr)
{
return $this->orX(Expr::key($keyName, $expr));
}
示例3: leaveExpression
/**
* {@inheritdoc}
*/
public function leaveExpression(Expression $expr)
{
if ($expr instanceof Key) {
switch ($expr->getKey()) {
case AssetMapping::UUID:
return Expr::key(BindingDescriptor::UUID, $expr->getExpression());
case AssetMapping::GLOB:
$queryExpr = $expr->getExpression();
if ($queryExpr instanceof Same) {
$queryExpr = Expr::same($queryExpr->getComparedValue() . '{,/**/*}');
} elseif ($queryExpr instanceof Equals) {
$queryExpr = Expr::equals($queryExpr->getComparedValue() . '{,/**/*}');
} elseif ($queryExpr instanceof NotSame) {
$queryExpr = Expr::notSame($queryExpr->getComparedValue() . '{,/**/*}');
} elseif ($queryExpr instanceof NotEquals) {
$queryExpr = Expr::notEquals($queryExpr->getComparedValue() . '{,/**/*}');
} elseif ($queryExpr instanceof EndsWith) {
$queryExpr = Expr::endsWith($queryExpr->getAcceptedSuffix() . '{,/**/*}');
}
return Expr::key(BindingDescriptor::QUERY, $queryExpr);
case AssetMapping::SERVER_NAME:
return Expr::key(BindingDescriptor::PARAMETER_VALUES, Expr::key(DiscoveryUrlGenerator::SERVER_PARAMETER, $expr->getExpression()));
case AssetMapping::SERVER_PATH:
return Expr::key(BindingDescriptor::PARAMETER_VALUES, Expr::key(DiscoveryUrlGenerator::PATH_PARAMETER, $expr->getExpression()));
}
}
return $expr;
}
示例4: webPath
private function webPath($path)
{
return $this->defaultExpr()->andKey(BindingDescriptor::PARAMETER_VALUES, Expr::key(DiscoveryUrlGenerator::PATH_PARAMETER, Expr::same($path)));
}
示例5: transform
/**
* {@inheritdoc}
*/
protected function transform(Expression $expression)
{
$constraint = $expression->getConstraint();
return Expr::key($expression->getSelector(), new $constraint($expression->getValue()));
}
示例6: testRemovePackages
public function testRemovePackages()
{
$this->initDefaultManager();
$packageDir = $this->packageDir1;
$this->packageFileStorage->expects($this->once())->method('saveRootPackageFile')->with($this->rootPackageFile)->will($this->returnCallback(function (RootPackageFile $rootPackageFile) use($packageDir) {
PHPUnit_Framework_Assert::assertFalse($rootPackageFile->hasInstallInfo('vendor/package1'));
PHPUnit_Framework_Assert::assertFalse($rootPackageFile->hasInstallInfo('vendor/package2'));
PHPUnit_Framework_Assert::assertTrue($rootPackageFile->hasInstallInfo('vendor/package3'));
}));
$this->rootPackageFile->addInstallInfo($this->installInfo3);
$this->assertTrue($this->rootPackageFile->hasInstallInfo('vendor/package1'));
$this->assertTrue($this->rootPackageFile->hasInstallInfo('vendor/package2'));
$this->assertTrue($this->rootPackageFile->hasInstallInfo('vendor/package3'));
$this->assertTrue($this->manager->hasPackage('vendor/root'));
$this->assertTrue($this->manager->hasPackage('vendor/package1'));
$this->assertTrue($this->manager->hasPackage('vendor/package2'));
$this->assertTrue($this->manager->hasPackage('vendor/package3'));
$this->manager->removePackages(Expr::key(Package::NAME, Expr::endsWith('1')->orEndsWith('2')));
$this->assertFalse($this->rootPackageFile->hasInstallInfo('vendor/package1'));
$this->assertFalse($this->rootPackageFile->hasInstallInfo('vendor/package2'));
$this->assertTrue($this->rootPackageFile->hasInstallInfo('vendor/package3'));
$this->assertTrue($this->manager->hasPackage('vendor/root'));
$this->assertFalse($this->manager->hasPackage('vendor/package1'));
$this->assertFalse($this->manager->hasPackage('vendor/package2'));
$this->assertTrue($this->manager->hasPackage('vendor/package3'));
}
示例7: testMatch
public function testMatch()
{
$server = new Server('localhost', 'symlink', 'web', '/%s', array('param1' => 'value1', 'param2' => 'value2'));
$this->assertFalse($server->match(Expr::same('foobar', Server::NAME)));
$this->assertTrue($server->match(Expr::same('localhost', Server::NAME)));
$this->assertFalse($server->match(Expr::same('foobar', Server::INSTALLER_NAME)));
$this->assertTrue($server->match(Expr::same('symlink', Server::INSTALLER_NAME)));
$this->assertFalse($server->match(Expr::same('foobar', Server::DOCUMENT_ROOT)));
$this->assertTrue($server->match(Expr::same('web', Server::DOCUMENT_ROOT)));
$this->assertFalse($server->match(Expr::same('foobar', Server::URL_FORMAT)));
$this->assertTrue($server->match(Expr::same('/%s', Server::URL_FORMAT)));
$this->assertFalse($server->match(Expr::key(Server::PARAMETER_VALUES, Expr::keyExists('foobar'))));
$this->assertTrue($server->match(Expr::key(Server::PARAMETER_VALUES, Expr::keyExists('param1'))));
}
示例8: testMatch
public function testMatch()
{
$type = new BindingTypeDescriptor('vendor/type', null, array(new BindingParameterDescriptor('param')));
$type->load($this->package);
$uuid = Uuid::fromString('abcdb814-9dad-11d1-80b4-00c04fd430c8');
$this->package->getInstallInfo()->addEnabledBindingUuid($uuid);
$binding = new BindingDescriptor('/path', 'vendor/type', array('param' => 'value'), 'glob', $uuid);
$binding->load($this->package, $type);
$this->assertFalse($binding->match(Expr::same('foobar', BindingDescriptor::CONTAINING_PACKAGE)));
$this->assertTrue($binding->match(Expr::same($this->package->getName(), BindingDescriptor::CONTAINING_PACKAGE)));
$this->assertFalse($binding->match(Expr::same(BindingState::DISABLED, BindingDescriptor::STATE)));
$this->assertTrue($binding->match(Expr::same(BindingState::ENABLED, BindingDescriptor::STATE)));
$this->assertFalse($binding->match(Expr::startsWith('abce', BindingDescriptor::UUID)));
$this->assertTrue($binding->match(Expr::startsWith('abcd', BindingDescriptor::UUID)));
$this->assertFalse($binding->match(Expr::same('/path/nested', BindingDescriptor::QUERY)));
$this->assertTrue($binding->match(Expr::same('/path', BindingDescriptor::QUERY)));
$this->assertFalse($binding->match(Expr::same('xpath', BindingDescriptor::LANGUAGE)));
$this->assertTrue($binding->match(Expr::same('glob', BindingDescriptor::LANGUAGE)));
$this->assertFalse($binding->match(Expr::same('vendor/other', BindingDescriptor::TYPE_NAME)));
$this->assertTrue($binding->match(Expr::same('vendor/type', BindingDescriptor::TYPE_NAME)));
$this->assertFalse($binding->match(Expr::key(BindingDescriptor::PARAMETER_VALUES, Expr::key('param', Expr::same('foobar')))));
$this->assertTrue($binding->match(Expr::key(BindingDescriptor::PARAMETER_VALUES, Expr::key('param', Expr::same('value')))));
}
示例9: testMatch
public function testMatch()
{
$target = new InstallTarget('local', 'symlink', 'web', '/%s', array('param1' => 'value1', 'param2' => 'value2'));
$this->assertFalse($target->match(Expr::same('foobar', InstallTarget::NAME)));
$this->assertTrue($target->match(Expr::same('local', InstallTarget::NAME)));
$this->assertFalse($target->match(Expr::same('foobar', InstallTarget::INSTALLER_NAME)));
$this->assertTrue($target->match(Expr::same('symlink', InstallTarget::INSTALLER_NAME)));
$this->assertFalse($target->match(Expr::same('foobar', InstallTarget::LOCATION)));
$this->assertTrue($target->match(Expr::same('web', InstallTarget::LOCATION)));
$this->assertFalse($target->match(Expr::same('foobar', InstallTarget::URL_FORMAT)));
$this->assertTrue($target->match(Expr::same('/%s', InstallTarget::URL_FORMAT)));
$this->assertFalse($target->match(Expr::key(InstallTarget::PARAMETER_VALUES, Expr::keyExists('foobar'))));
$this->assertTrue($target->match(Expr::key(InstallTarget::PARAMETER_VALUES, Expr::keyExists('param1'))));
}
示例10: andKey
public function andKey($keyName, Expression $expr)
{
return $this->andX(Expr::key($keyName, $expr));
}
示例11: webPath
private function webPath($path)
{
return $this->defaultExpr()->andKey(BindingDescriptor::PARAMETER_VALUES, Expr::key(AssetPlugin::PATH_PARAMETER, Expr::same($path)));
}