當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。