hshn / class-matcher-bundle
v0.1.0
2014-08-06 17:02 UTC
Requires
- php: >=5.4
- hshn/class-matcher: ~0.2
- symfony/framework-bundle: ~2.1
Requires (Dev)
- symfony/browser-kit: ~2.1
This package is not auto-updated.
Last update: 2024-09-24 02:18:50 UTC
README
简化在Symfony中定义类匹配器作为服务的过程。
配置
# app/config/config.yml hshn_class_matcher: matchers: matcher1: { equals: FooExtended } # matches FooExtended matcher2: { implemented: FooInterface } # matches class that implements FooInterface matcher3: { extended: Foo } # matches class that extends Foo matcher4: { anything: ~ } # matches anything matcher5: { and: [matcher1, matcher3] } # matches class that matches matcher 'matcher1' and 'matcher3' matcher6: { or: [matcher1, matcher2] } # matches class that matches matcher 'matcher1' or 'matcher2' matcher7: { not: matcher3 } # matches class that do not extends Foo
用法
<?php $provider = $container->get('hshn_class_matcher.matcher_provider'); $provider->get('matcher1')->matches('Foo'); // true or false