本文整理汇总了PHP中Zend\Filter\FilterChain::attach方法的典型用法代码示例。如果您正苦于以下问题:PHP FilterChain::attach方法的具体用法?PHP FilterChain::attach怎么用?PHP FilterChain::attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Filter\FilterChain
的用法示例。
在下文中一共展示了FilterChain::attach方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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);
}
示例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: _convertTableNameToClassName
protected function _convertTableNameToClassName($tableName)
{
if ($this->_nameFilter == null) {
$this->_nameFilter = new \Zend\Filter\FilterChain();
$this->_nameFilter->attach(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: 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;
}
示例8: 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;
}
示例9: testAllowsConnectingArbitraryCallbacks
public function testAllowsConnectingArbitraryCallbacks()
{
$chain = new FilterChain();
$chain->attach(function($value) {
return strtolower($value);
});
$value = 'AbC';
$this->assertEquals('abc', $chain->filter($value));
}
示例10: 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());
}
示例11: __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);
}
示例12: 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);
}
示例13: 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);
}
}
}
示例14: __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;
}
}
示例15: _convertActionNameToFilesystemName
protected function _convertActionNameToFilesystemName($actionName)
{
$filter = new FilterChain();
$filter->attach(new CamelCaseToDashFilter())->attach(new StringToLowerFilter());
return $filter->filter($actionName);
}