本文整理汇总了PHP中Zend\Filter\FilterChain::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP FilterChain::filter方法的具体用法?PHP FilterChain::filter怎么用?PHP FilterChain::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Filter\FilterChain
的用法示例。
在下文中一共展示了FilterChain::filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter
/**
* Filter an array's values
* @param mixed $value
* @return mixed
*/
public function filter($value)
{
// Don't touch non-array things
if (!is_array($value) || !$this->chain) {
return $value;
}
// Apply sub-filters to all values
foreach ($value as &$v) {
$v = $this->chain->filter($v);
}
return $value;
}
示例2: 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;
}
示例3: _filter
public function _filter(&$value)
{
$filtered = parent::filter($value);
$changed = $filtered != $value;
$value = $filtered;
return $changed;
}
示例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: _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);
}
示例6: 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);
}
示例7: 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());
}
示例8: 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);
}
示例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: filterName
/**
* @param \AGmakonts\STL\String\String $name
*
* @return \AGmakonts\STL\String\String
*/
private static function filterName(string $name) : string
{
$nameValue = $name->value();
$filterChain = new FilterChain();
$filterChain->attach(new StripNewlines());
$filterChain->attach(new StripTags());
$filterChain->attach(new StringTrim());
$filterChain->attach(new StringToLower());
$filterChain->attach(new Callback(function ($value) {
return ucwords($value);
}));
$filteredValue = $filterChain->filter($nameValue);
return String::get($filteredValue);
}
示例11: 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;
}
示例12: loadMenu
/**
* Load menu if module has view with name "menu.phtml"
*
* @param EventInterface $event Event
*
* @return void
*/
public function loadMenu(EventInterface $event)
{
if ($route = $event->getRouter()->getRoute('module')->match($event->getRequest())) {
if ($route->getParam('module') === 'module') {
return;
}
$filter = new Filter\Word\CamelCaseToSeparator();
$filter->setSeparator('-');
$filterChain = new Filter\FilterChain();
$filterChain->attach($filter)->attach(new Filter\StringToLower());
$template = $filterChain->filter($route->getParam('module')) . '/menu';
$target = $event->getTarget();
$resolver = $event->getApplication()->getServiceManager()->get('Zend\\View\\Resolver\\TemplatePathStack');
$navigation = $target->getServiceLocator()->get('navigation');
$navigation->findByRoute('module')->addPage(array('label' => $route->getParam('module'), 'route' => $event->getRouteMatch()->getMatchedRouteName(), 'active' => true));
if (false !== $resolver->resolve($template)) {
$target->layout()->setVariable('moduleMenu', $template);
}
}
}
示例13: __construct
/**
* Public constructor
*
* @param SparqlClient $sparqlClient A SparQL client
* @param String $query_path Path to sparQL queries
* @param Cache $cache Cache
* @throws \Exception
*/
public function __construct(SparqlClient $sparqlClient, $query_path, Cache $cache = null)
{
$this->sparqlClient = $sparqlClient;
if (!file_exists($query_path) || !is_dir($query_path)) {
$tpl = "Query path '%s' does not exist or is not a directory";
$msg = sprintf($tpl, $query_path);
throw new \Exception($msg);
}
$filter = new FilterChain();
$filter->attach(new StringToLowerFilter())->attach(new WordFilter\SeparatorToCamelCase())->attach(new WordFilter\DashToCamelCase())->attach(new WordFilter\UnderscoreToCamelCase())->attach(new CallbackFilter('lcfirst'));
$flags = \FilesystemIterator::KEY_AS_FILENAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS;
$fsi = new \FilesystemIterator($query_path, $flags);
$rei = new \RegexIterator($fsi, '/\\.rq$/');
foreach ($rei as $fileName => $fileInfo) {
$path = $fileInfo->getPathname();
$baseName = $fileInfo->getBasename('.rq');
$propName = $filter->filter($baseName);
$this->queries[$propName] = file_get_contents($path);
}
if (null != $cache) {
$this->cache = $cache;
}
}
示例14: _convertActionNameToFilesystemName
protected function _convertActionNameToFilesystemName($actionName)
{
$filter = new FilterChain();
$filter->attach(new CamelCaseToDashFilter())->attach(new StringToLowerFilter());
return $filter->filter($actionName);
}
示例15: filter
public function filter($value)
{
$filterChain = new ZFilter\FilterChain();
$filterChain->attach(new \Zend\I18n\Filter\Alnum(true))->attach(new ZFilter\StringTrim())->attach(new ZFilter\PregReplace(array("pattern" => "#\\s+#", "replacement" => " ")))->attach(new ZFilter\StringToLower("UTF-8"))->attach(new ZFilter\Word\SeparatorToDash())->attach(new \ZendVN\Filter\RemoveCircumPlex());
return $output = $filterChain->filter($value);
}