当前位置: 首页>>代码示例>>PHP>>正文


PHP FilterChain::attachByName方法代码示例

本文整理汇总了PHP中Zend\Filter\FilterChain::attachByName方法的典型用法代码示例。如果您正苦于以下问题:PHP FilterChain::attachByName方法的具体用法?PHP FilterChain::attachByName怎么用?PHP FilterChain::attachByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Filter\FilterChain的用法示例。


在下文中一共展示了FilterChain::attachByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:UnderscoreNamingStrategy.php

示例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;
         }
     }
 }
开发者ID:API-Skeletons,项目名称:zf-apigility-doctrine,代码行数:32,代码来源:DoctrineMetadata1Test.php

示例3: testAllowsConnectingViaClassShortName

 public function testAllowsConnectingViaClassShortName()
 {
     $chain = new FilterChain();
     $chain->attachByName('string_trim', array('encoding' => 'utf-8'), 100)->attachByName('strip_tags')->attachByName('string_to_lower', array('encoding' => 'utf-8'), 900);
     $value = '<a name="foo"> ABC </a>';
     $valueExpected = 'abc';
     $this->assertEquals($valueExpected, $chain->filter($value));
 }
开发者ID:rexmac,项目名称:zf2,代码行数:8,代码来源:FilterChainTest.php

示例4: getNormalizationFilter

 /**
  * 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;
 }
开发者ID:API-Skeletons,项目名称:zf-apigility-doctrine,代码行数:14,代码来源:DoctrineRpcServiceModel.php

示例5: filterNamespaceToDirectory

 /**
  * @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;
 }
开发者ID:sandrokeil,项目名称:prooph-cli,代码行数:12,代码来源:Psr4Info.php

示例6: 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;
 }
开发者ID:alapini,项目名称:apigility-3hr-tutorial,代码行数:14,代码来源:RestServiceModel.php

示例7: filterNamespaceToDirectory

 /**
  * @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;
 }
开发者ID:prolic,项目名称:prooph-cli,代码行数:12,代码来源:Psr4Info.php

示例8: 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(CamelCaseToDash::class)->attachByName(StringToLower::class);
     return $this->routeNameFilter;
 }
开发者ID:zfcampus,项目名称:zf-apigility-doctrine,代码行数:14,代码来源:DoctrineRestServiceModel.php

示例9: testAllowsConnectingViaClassShortName

 public function testAllowsConnectingViaClassShortName()
 {
     if (!function_exists('mb_strtolower')) {
         $this->markTestSkipped('mbstring required');
     }
     $chain = new FilterChain();
     $chain->attachByName('string_trim', null, 100)->attachByName('strip_tags')->attachByName('string_to_lower', array('encoding' => 'utf-8'), 900);
     $value = '<a name="foo"> ABC </a>';
     $valueExpected = 'abc';
     $this->assertEquals($valueExpected, $chain->filter($value));
 }
开发者ID:navassouza,项目名称:zf2,代码行数:11,代码来源:FilterChainTest.php

示例10: extract

 public function extract($value)
 {
     if (!method_exists($value, 'getTypeClass')) {
         return;
     }
     $config = $this->getMetadataMap()[$value->getTypeClass()->name];
     $filter = new FilterChain();
     $filter->attachByName('WordCamelCaseToUnderscore')->attachByName('StringToLower');
     // Better way to create mapping name?
     // FIXME: use zf-hal collection_name
     $link = new Link('self');
     $link->setRoute($config['route_name']);
     $link->setRouteParams(array('id' => null));
     $filterValue = array('field' => $value->getMapping()['mappedBy'] ?: $value->getMapping()['inversedBy'], 'type' => isset($value->getMapping()['joinTable']) ? 'ismemberof' : 'eq', 'value' => $value->getOwner()->getId());
     $link->setRouteOptions(array('query' => array($this->getFilterKey() => array($filterValue))));
     $linkCollection = new LinkCollection();
     $linkCollection->add($link);
     $halEntity = new HalEntity(new stdClass());
     $halEntity->setLinks($linkCollection);
     return $halEntity;
 }
开发者ID:api-skeletons,项目名称:zf-doctrine-hydrator,代码行数:21,代码来源:CollectionLink.php

示例11: extract

 public function extract($value)
 {
     $config = $this->getServiceManager()->get('Config');
     if (!method_exists($value, 'getTypeClass') || !isset($config['zf-hal']['metadata_map'][$value->getTypeClass()->name])) {
         return;
     }
     $config = $config['zf-hal']['metadata_map'][$value->getTypeClass()->name];
     $mapping = $value->getMapping();
     $filter = new FilterChain();
     $filter->attachByName('WordCamelCaseToUnderscore')->attachByName('StringToLower');
     $link = new Link($filter($mapping['fieldName']));
     $link->setRoute($config['route_name']);
     $link->setRouteParams(array('id' => null));
     if (isset($config['zf-doctrine-querybuilder-options']['filter_key'])) {
         $filterKey = $config['zf-doctrine-querybuilder-options']['filter_key'];
     } else {
         $filterKey = 'filter';
     }
     $link->setRouteOptions(array('query' => array($filterKey => array(array('field' => $mapping['mappedBy'], 'type' => 'eq', 'value' => $value->getOwner()->getId())))));
     return $link;
 }
开发者ID:Kwido,项目名称:zf-doctrine-querybuilder,代码行数:21,代码来源:CollectionLink.php

示例12: testBuildOrmApi

 public function testBuildOrmApi()
 {
     $serviceManager = $this->getApplication()->getServiceManager();
     $em = $serviceManager->get('doctrine.entitymanager.orm_default');
     $tool = new SchemaTool($em);
     $res = $tool->createSchema($em->getMetadataFactory()->getAllMetadata());
     // Create DB
     $resource = $serviceManager->get('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceResource');
     $artistResourceDefinition = array("objectManager" => "doctrine.entitymanager.orm_default", "serviceName" => "Artist", "entityClass" => "ZFTestApigilityDb\\Entity\\Artist", "routeIdentifierName" => "artist_id", "entityIdentifierName" => "id", "routeMatch" => "/test/rest/artist", "collectionHttpMethods" => array(0 => 'GET', 1 => 'POST', 2 => 'PATCH', 3 => 'DELETE'));
     $artistResourceDefinitionWithNonKeyIdentifer = array("objectManager" => "doctrine.entitymanager.orm_default", "serviceName" => "ArtistByName", "entityClass" => "ZFTestApigilityDb\\Entity\\Artist", "routeIdentifierName" => "artist_name", "entityIdentifierName" => "name", "routeMatch" => "/test/rest/artist-by-name", "collectionHttpMethods" => array(0 => 'GET'));
     // This route is what should be an rpc service, but an user could do
     $albumResourceDefinition = array("objectManager" => "doctrine.entitymanager.orm_default", "serviceName" => "Album", "entityClass" => "ZFTestApigilityDb\\Entity\\Album", "routeIdentifierName" => "album_id", "entityIdentifierName" => "id", "routeMatch" => "/test/rest[/artist/:artist_id]/album[/:album_id]", "collectionHttpMethods" => array(0 => 'GET', 1 => 'POST', 2 => 'PATCH', 3 => 'DELETE'));
     $resource->setModuleName('ZFTestApigilityDbApi');
     $artistEntity = $resource->create($artistResourceDefinition);
     $artistEntity = $resource->create($artistResourceDefinitionWithNonKeyIdentifer);
     $albumEntity = $resource->create($albumResourceDefinition);
     $this->assertInstanceOf('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceEntity', $artistEntity);
     $this->assertInstanceOf('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRestServiceEntity', $albumEntity);
     // Build relation
     $filter = new FilterChain();
     $filter->attachByName('WordCamelCaseToUnderscore')->attachByName('StringToLower');
     $em = $serviceManager->get('doctrine.entitymanager.orm_default');
     $metadataFactory = $em->getMetadataFactory();
     $entityMetadata = $metadataFactory->getMetadataFor("ZFTestApigilityDb\\Entity\\Artist");
     $rpcServiceResource = $serviceManager->get('ZF\\Apigility\\Doctrine\\Admin\\Model\\DoctrineRpcServiceResource');
     $rpcServiceResource->setModuleName('ZFTestApigilityDbApi');
     foreach ($entityMetadata->associationMappings as $mapping) {
         switch ($mapping['type']) {
             case 4:
                 $rpcServiceResource->create(array('service_name' => 'Artist' . $mapping['fieldName'], 'route' => '/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;
         }
     }
 }
开发者ID:API-Skeletons,项目名称:zf-apigility-doctrine,代码行数:36,代码来源:ApigilityTest.php

示例13: testClone

 public function testClone()
 {
     $chain = new FilterChain();
     $clone = clone $chain;
     $chain->attachByName('strip_tags');
     $this->assertCount(0, $clone);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:7,代码来源:FilterChainTest.php

示例14: index18Action

 public function index18Action()
 {
     echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>";
     $input = "            Trongle123123-Handsome-Talent         ";
     $filterChain = new ZFilter\FilterChain();
     $filterChain->attachByName("StringTrim");
     $filterChain->attachByName("PregReplace", array("pattern" => "#[0-9]#", "replacement" => "!"));
     $filterChain->attachByName("Word\\DashToUnderscore");
     $output = $filterChain->filter($input);
     echo "<h2>Input: {$input}</h2><br>";
     echo "<h2>Output : {$output}</h2>";
     return false;
 }
开发者ID:trongle,项目名称:zend-2,代码行数:13,代码来源:FilterController.php

示例15: populateFilters

 /**
  * @param  FilterChain       $chain
  * @param  array|Traversable $filters
  * @throws Exception\RuntimeException
  * @return void
  */
 protected function populateFilters(FilterChain $chain, $filters)
 {
     foreach ($filters as $filter) {
         if (is_object($filter) || is_callable($filter)) {
             $chain->attach($filter);
             continue;
         }
         if (is_array($filter)) {
             if (!isset($filter['name'])) {
                 throw new Exception\RuntimeException('Invalid filter specification provided; does not include "name" key');
             }
             $name = $filter['name'];
             $priority = isset($filter['priority']) ? $filter['priority'] : FilterChain::DEFAULT_PRIORITY;
             $options = [];
             if (isset($filter['options'])) {
                 $options = $filter['options'];
             }
             $chain->attachByName($name, $options, $priority);
             continue;
         }
         throw new Exception\RuntimeException('Invalid filter specification provided; was neither a filter instance nor an array specification');
     }
 }
开发者ID:jbmchd,项目名称:semente.lanches,代码行数:29,代码来源:Factory.php


注:本文中的Zend\Filter\FilterChain::attachByName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。