本文整理汇总了PHP中Zend\Filter\FilterChain类的典型用法代码示例。如果您正苦于以下问题:PHP FilterChain类的具体用法?PHP FilterChain怎么用?PHP FilterChain使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FilterChain类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: injectValidatorPluginManager
public static function injectValidatorPluginManager(Form $form, ServiceLocatorInterface $sl)
{
$plugins = $sl->get('ValidatorManager');
$chain = new FilterChain();
$chain->setPluginManager($plugins);
$form->getFormFactory()->getInputFilterFactory()->setDefaultFilterChain($chain);
}
示例2: testDoctrineService
public function testDoctrineService()
{
$serviceManager = $this->getApplication()->getServiceManager();
$em = $serviceManager->get('doctrine.entitymanager.orm_default');
$tool = new SchemaTool($em);
$res = $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
// Create DB
$resourceDefinition = array("objectManager" => "doctrine.entitymanager.orm_default", "serviceName" => "Artist", "entityClass" => "Db\\Entity\\Artist", "routeIdentifierName" => "artist_id", "entityIdentifierName" => "id", "routeMatch" => "/db-test/artist");
$this->resource = $serviceManager->get('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceResource');
$this->resource->setModuleName('DbApi');
$entity = $this->resource->create($resourceDefinition);
$this->assertInstanceOf('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceEntity', $entity);
$controllerServiceName = $entity->controllerServiceName;
$this->assertNotEmpty($controllerServiceName);
$this->assertContains('DbApi\\V1\\Rest\\Artist\\Controller', $controllerServiceName);
$filter = new FilterChain();
$filter->attachByName('WordCamelCaseToUnderscore')->attachByName('StringToLower');
$em = $serviceManager->get('doctrine.entitymanager.orm_default');
$metadataFactory = $em->getMetadataFactory();
$entityMetadata = $metadataFactory->getMetadataFor("Db\\Entity\\Artist");
foreach ($entityMetadata->associationMappings as $mapping) {
switch ($mapping['type']) {
case 4:
$rpcServiceResource = $serviceManager->get('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRpcServiceResource');
$rpcServiceResource->setModuleName('DbApi');
$rpcServiceResource->create(array('service_name' => 'Artist' . $mapping['fieldName'], 'route' => '/db-test/artist[/:parent_id]/' . $filter($mapping['fieldName']) . '[/:child_id]', 'http_methods' => array('GET', 'PUT', 'POST'), 'options' => array('target_entity' => $mapping['targetEntity'], 'source_entity' => $mapping['sourceEntity'], 'field_name' => $mapping['fieldName']), 'selector' => 'custom selector'));
break;
default:
break;
}
}
}
示例3: filter
public static function filter($input)
{
$filterChain = new ZFilter\FilterChain();
$filterChain->attach(new ZFilter\StringToLower(array('encoding' => 'UTF-8')))->attach(new \Zend\I18n\Filter\Alnum(true))->attach(new \ZendVN\Filter\RemoveCircuflex())->attach(new \Zend\Filter\PregReplace(array('pattern' => '#\\s+#', 'replacement' => '-')))->attach(new \Zend\Filter\Word\CamelCaseToDash());
$output = $filterChain->filter($input);
return $output;
}
示例4: __call
public function __call($method, $args)
{
$filterChain = new FilterChain();
$filterChain->attach(new CamelCaseToDash())->attach(new StringToLower());
$icon = $filterChain->filter($method);
return $this->render($icon, isset($args[0]) ? $args[0] : '', isset($args[1]) ? $args[1] : false);
}
示例5: testFilterPrependOrder
/**
* Ensures that filters can be prepended and will be executed in the
* expected order
*/
public function testFilterPrependOrder()
{
$filter = new FilterChain();
$filter->appendFilter(new StripUpperCase())->prependFilter(new LowerCase());
$value = 'AbC';
$valueExpected = 'abc';
$this->assertEquals($valueExpected, $filter($value));
}
示例6: getFilter
/**
* @return \Zend\Filter\FilterChain
*/
private function getFilter()
{
if ($this->filter === null) {
$filter = new FilterChain();
$filter->attach(new CamelCaseToDash());
$filter->attach(new StringToLower());
$this->filter = $filter;
}
return $this->filter;
}
示例7: getCamelCaseToUnderscoreFilter
/**
* @return FilterChain
*/
protected function getCamelCaseToUnderscoreFilter()
{
if (static::$camelCaseToUnderscoreFilter instanceof FilterChain) {
return static::$camelCaseToUnderscoreFilter;
}
$filter = new FilterChain();
$filter->attachByName('WordCamelCaseToUnderscore');
$filter->attachByName('StringToLower');
return static::$camelCaseToUnderscoreFilter = $filter;
}
示例8: indexAction
/**
* List all modules
*
* @return \Zend\View\Model\ViewModel
*/
public function indexAction()
{
$collection = new ModuleCollection();
$filter = new Filter\Word\CamelCaseToSeparator();
$filter->setSeparator('-');
$filterChain = new Filter\FilterChain();
$filterChain->attach($filter)->attach(new Filter\StringToLower());
foreach ($collection->getModules() as $module) {
$module->setData('route', $filterChain->filter($module->getName()));
}
return array('modules' => $collection->getModules());
}
示例9: __call
/**
* Display Icon
*
* @param string $method
* @param array $argv
* @throws \InvalidArgumentException
* @return string
*/
public function __call($method, $argv)
{
$filterChain = new FilterChain();
$filterChain->attach(new CamelCaseToDash())->attach(new StringToLower());
$icon = $filterChain->filter($method);
if (!in_array($icon, $this->icons)) {
throw new InvalidArgumentException($icon . ' is not supported');
}
if ($argv) {
$argv = (string) $argv[0];
}
return $this->render($icon, $argv);
}
示例10: filter
/**
* Filters a value with given filters.
*
* @param mixed $value
* @param array $filters
* @return mixed
* @throws InvalidFilterException If callback is not callable.
*/
public function filter($value, array $filters)
{
$filterChain = new FilterChain();
foreach ($filters as $name => $options) {
$class = 'Zend\\Filter\\' . ucfirst($name);
if (class_exists($class)) {
$filterChain->attach(new $class($options));
} else {
throw new InvalidFilterException("{$class} class does not exist.");
}
}
return $filterChain->filter($value);
}
示例11: normalizeTag
/**
* Normalize tag
*
* Ensures tag is alphanumeric characters only, and all lowercase.
*
* @param string $tag
* @return string
*/
public function normalizeTag($tag)
{
if (!isset($this->_tagFilter)) {
$this->_tagFilter = new Filter\FilterChain();
$this->_tagFilter->attach(new Filter\Alnum())->attach(new Filter\StringToLower());
}
return $this->_tagFilter->filter($tag);
}
示例12: _convertTableNameToClassName
protected function _convertTableNameToClassName($tableName)
{
if ($this->_nameFilter == null) {
$this->_nameFilter = new \Zend\Filter\FilterChain();
$this->_nameFilter->addFilter(new \Zend\Filter\Word\UnderscoreToCamelCase());
}
return $this->_nameFilter->filter($tableName);
}
示例13: provide
/**
* {@inheritDoc}
*/
public function provide()
{
$container = [];
$terms = $this->taxonomyManager->findAllTerms(true);
$notTrashed = new NotTrashedCollectionFilter();
$typeFilter = new TaxonomyTypeCollectionFilter(['curriculum-topic', 'curriculum-topic-folder']);
$chain = new FilterChain();
$chain->attach($notTrashed);
$chain->attach($typeFilter);
$terms = $chain->filter($terms);
/* @var $term TaxonomyTermInterface */
foreach ($terms as $term) {
$result = $this->toDocument($term);
$container[] = $result;
}
return $container;
}
示例14: getRouteNameFilter
/**
* Retrieve the filter chain for generating the route name
*
* @return FilterChain
*/
protected function getRouteNameFilter()
{
if ($this->routeNameFilter instanceof FilterChain) {
return $this->routeNameFilter;
}
$this->routeNameFilter = new FilterChain();
$this->routeNameFilter->attachByName('Word\\CamelCaseToDash')->attachByName('StringToLower');
return $this->routeNameFilter;
}
示例15: filterNamespaceToDirectory
/**
* @return FilterChain
*/
private function filterNamespaceToDirectory()
{
if (null === $this->filterNamespaceToDirectory) {
$this->filterNamespaceToDirectory = new FilterChain();
$this->filterNamespaceToDirectory->attach(new SeparatorToSeparator('\\', '|'));
$this->filterNamespaceToDirectory->attach(new SeparatorToSeparator('|', DIRECTORY_SEPARATOR));
}
return $this->filterNamespaceToDirectory;
}