作者:soflom
项目:commo
public static function injectValidatorPluginManager(Form $form, ServiceLocatorInterface $sl)
{
$plugins = $sl->get('ValidatorManager');
$chain = new FilterChain();
$chain->setPluginManager($plugins);
$form->getFormFactory()->getInputFilterFactory()->setDefaultFilterChain($chain);
}
作者:API-Skeleton
项目:zf-apigility-doctrin
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;
}
}
}
作者:quangdungnin
项目:zendvntea
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;
}
作者:acpl
项目:acplou
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);
}
作者:stunt
项目:zf
/**
* 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));
}
作者:spryke
项目:Kerne
/**
* @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;
}
作者:aWEBoLab
项目:tax
/**
* @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;
}
作者:gotcm
项目:gotcm
/**
* 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());
}
作者:suitedJ
项目:ZfcTwitterBootstra
/**
* 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);
}
作者:lfbittencour
项目:fewte
/**
* 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);
}
作者:bradley-hol
项目:zf
/**
* 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);
}
作者:heiglandrea
项目:zf
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);
}
作者:Rahsi
项目:athene
/**
* {@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;
}
作者:alapin
项目:apigility-3hr-tutoria
/**
* 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;
}
作者:proophsoftwar
项目:prooph-cl
/**
* @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;
}
作者:sandrokei
项目:prooph-cl
/**
* @return FilterChain
*/
private function filterNamespaceToDirectory()
{
if (null === $this->filterNamespaceToDirectory) {
$this->filterNamespaceToDirectory = new FilterChain();
$this->filterNamespaceToDirectory->attachByName('wordseparatortocamelcase', ['separator' => '\\']);
$this->filterNamespaceToDirectory->attachByName('wordcamelcasetoseparator', ['separator' => '/']);
}
return $this->filterNamespaceToDirectory;
}
作者:proli
项目:prooph-cl
/**
* @return FilterChain
*/
private function filterNamespaceToDirectory()
{
if (null === $this->filterNamespaceToDirectory) {
$this->filterNamespaceToDirectory = new FilterChain();
$this->filterNamespaceToDirectory->attachByName('wordseparatortoseparator', ['search_separator' => '\\', 'replacement_separator' => '|']);
$this->filterNamespaceToDirectory->attachByName('wordseparatortoseparator', ['search_separator' => '|', 'replacement_separator' => DIRECTORY_SEPARATOR]);
}
return $this->filterNamespaceToDirectory;
}
作者:zfcampu
项目:zf-apigility-doctrin
/**
* 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(CamelCaseToDash::class)->attachByName(StringToLower::class);
return $this->routeNameFilter;
}
作者:API-Skeleton
项目:zf-apigility-doctrin
/**
* Retrieve and/or initialize the normalization filter chain
*
* @return FilterChain
*/
protected function getNormalizationFilter()
{
if ($this->filter instanceof FilterChain) {
return $this->filter;
}
$this->filter = new FilterChain();
$this->filter->attachByName('WordCamelCaseToDash')->attachByName('StringToLower');
return $this->filter;
}
作者:gridguy
项目:zor
/**
* Get current input filter factory
*
* If none provided, uses an unconfigured instance.
*
* @return InputFilterFactory
*/
public function getInputFilterFactory()
{
$inputFilterFactory = parent::getInputFilterFactory();
if (!$this->inputFilterFactoryDefaultsInitialized) {
$this->inputFilterFactoryDefaultsInitialized = true;
$dfc = $inputFilterFactory->getDefaultFilterChain();
$dvc = $inputFilterFactory->getDefaultValidatorChain();
if (empty($dfc)) {
$inputFilterFactory->setDefaultFilterChain($dfc = new FilterChain());
}
if (empty($dvc)) {
$inputFilterFactory->setDefaultValidatorChain($dvc = new ValidatorChain());
}
$initializer = array($this, 'initializeApplicationServiceLocators');
$dfc->getPluginManager()->addInitializer($initializer, false);
$dvc->getPluginManager()->addInitializer($initializer, false);
}
return $inputFilterFactory;
}