protected function _convertActionNameToFilesystemName($actionName) { $filter = new \Zend\Filter\FilterChain(); $filter->addFilter(new \Zend\Filter\Word\CamelCaseToDash())->addFilter(new \Zend\Filter\StringToLower()); return $filter->filter($actionName); }
public function index29Action() { $input = ' zend_framework_is_not_difficult '; $filterChain = new \Zend\Filter\FilterChain(); $filterChain->attachByName('StringToUpper')->attachByName('StringTrim')->attachByName('Word\\UnderscoreToDash'); $output = $filterChain->filter($input); echo "<h3>" . $input . "</h3>"; echo "<h3>" . $output . "</h3>"; return false; }
/** * getMetadata() is required by the Manifest Interface. * * These are the following metadatas that will be setup: * * actionName * - metadata for actions * - value will be a dashed name for the action named in 'actionName' * providerName * - metadata for providers * - value will be a dashed-name for the provider named in 'providerName' * providerSpecialtyNames * - metadata for providers * actionableMethodLongParameters * - metadata for providers * actionableMethodShortParameters * - metadata for providers * * @return array Array of Metadatas */ public function getMetadata() { $metadatas = array(); // setup the camelCase to dashed filter to use since cli expects dashed named $ccToDashedFilter = new \Zend\Filter\FilterChain(); $ccToDashedFilter->addFilter(new \Zend\Filter\Word\CamelCaseToDash())->addFilter(new \Zend\Filter\StringToLower()); // get the registry to get the action and provider repository $actionRepository = $this->_registry->getActionRepository(); $providerRepository = $this->_registry->getProviderRepository(); // loop through all actions and create a metadata for each foreach ($actionRepository->getActions() as $action) { // each action metadata will be called $metadatas[] = new Metadata\Tool(array('name' => 'actionName', 'value' => $ccToDashedFilter->filter($action->getName()), 'reference' => $action, 'actionName' => $action->getName(), 'clientName' => 'console', 'clientReference' => $this->_registry->getClient())); } foreach ($providerRepository->getProviderSignatures() as $providerSignature) { // create the metadata for the provider's cliProviderName $metadatas[] = new Metadata\Tool(array('name' => 'providerName', 'value' => $ccToDashedFilter->filter($providerSignature->getName()), 'reference' => $providerSignature, 'clientName' => 'console', 'providerName' => $providerSignature->getName(), 'clientReference' => $this->_registry->getClient())); // create the metadatas for the per provider specialites in providerSpecaltyNames foreach ($providerSignature->getSpecialties() as $specialty) { $metadatas[] = new Metadata\Tool(array('name' => 'specialtyName', 'value' => $ccToDashedFilter->filter($specialty), 'reference' => $providerSignature, 'clientName' => 'console', 'providerName' => $providerSignature->getName(), 'specialtyName' => $specialty, 'clientReference' => $this->_registry->getClient())); } // $actionableMethod is keyed by the methodName (but not used) foreach ($providerSignature->getActionableMethods() as $actionableMethodData) { $methodLongParams = array(); $methodShortParams = array(); // $actionableMethodData get both the long and short names foreach ($actionableMethodData['parameterInfo'] as $parameterInfoData) { // filter to dashed $methodLongParams[$parameterInfoData['name']] = $ccToDashedFilter->filter($parameterInfoData['name']); // simply lower the character, (its only 1 char after all) $methodShortParams[$parameterInfoData['name']] = strtolower($parameterInfoData['name'][0]); } // create metadata for the long name cliActionableMethodLongParameters $metadatas[] = new Metadata\Tool(array('name' => 'actionableMethodLongParams', 'value' => $methodLongParams, 'clientName' => 'console', 'providerName' => $providerSignature->getName(), 'specialtyName' => $actionableMethodData['specialty'], 'actionName' => $actionableMethodData['actionName'], 'reference' => &$actionableMethodData, 'clientReference' => $this->_registry->getClient())); // create metadata for the short name cliActionableMethodShortParameters $metadatas[] = new Metadata\Tool(array('name' => 'actionableMethodShortParams', 'value' => $methodShortParams, 'clientName' => 'console', 'providerName' => $providerSignature->getName(), 'specialtyName' => $actionableMethodData['specialty'], 'actionName' => $actionableMethodData['actionName'], 'reference' => &$actionableMethodData, 'clientReference' => $this->_registry->getClient())); } } return $metadatas; }
protected function _convertControllerNameToFilesystemName($controllerName) { $filter = new \Zend\Filter\FilterChain(); $filter->attach(new \Zend\Filter\Word\CamelCaseToDash())->attach(new \Zend\Filter\StringToLower()); return $filter->filter($controllerName); }
/** * 設定關鍵字 * @param $data * @param $pageRes */ public function setTags($data, $pageRes) { $em = $this->getEntityManager(); foreach ($pageRes->getPageTags() as $tag) { $em->remove($tag); } $em->flush(); $filterChain = new \Zend\Filter\FilterChain(); $filterChain->attach(new \Zend\Filter\StringTrim())->attach(new \Zend\Filter\StripTags()); foreach (explode(",", $data['tags']) as $val) { $val = $filterChain->filter($val); if (!$val) { continue; } $tagRes = $em->getRepository('Base\\Entity\\PageTag')->findOneBy(array('tag_name' => $val)); if (!$tagRes) { $tagRes = new \Base\Entity\PageTag(); $tagRes->setTagName($val); $em->persist($tagRes); $em->flush(); } $tagRes->addPage($pageRes); $em->persist($tagRes); } $em->flush(); }
/** * Call */ public function call() { //print_r('MiddlewareTest middleware call method------'); //print_r($this->next); //Read flash messaging from previous request if available //$this->loadMessages(); //Prepare flash messaging for current request //$env = $this->app->environment(); //$env['slim.flash'] = $this; // Create a filter chain and filter for usage $filterChain = new \Zend\Filter\FilterChain(); $filterChain->attach(new \Zend\Filter\StripTags())->attach(new \Zend\Filter\StringTrim())->attach(new \Zend\Filter\HtmlEntities())->attach(new \Zend\Filter\StripNewlines())->attach(new \Zend\Filter\StringToLower()); echo $filterChain->filter("deneme <a TEST href='test'>"); // Create a validator chain and add validators to it $validatorChain = new \Zend\Validator\ValidatorChain(); $validatorChain->attach(new \Zend\Validator\StringLength(array('min' => 6, 'max' => 12)))->attach(new \Zend\I18n\Validator\Alnum()); // Validate the username if ($validatorChain->isValid("testteeewwwwwwwwwwwww__")) { // username passed validation } else { // username failed validation; print reasons /* foreach ($validatorChain->getMessages() as $message) { echo "$message\n"; }*/ //$this->app->redirect('/error'); //$this->app->error(); //$this->app->halt(500, "info status test!!!!"); /*$this->app->contentType('application/json'); $this->app->halt(500, '{"error":"Something went wrong"}'); $this->app->stop();*/ //exit(); //$this->app->run(); /*$response = $this->app->response(); //Generate Response headers $response->header('Content-Type', "application/json"); $response->status(DEFAULT_RESPONSE_CODE); $response->header('Content-Length', '500'); $responseBody = array('message'=> $message); $response->body(json_encode($responseBody)); $response->send();*/ //ob_clean(); $publicHash = '3441df0babc2a2dda551d7cd39fb235bc4e09cd1e4556bf261bb49188f548348'; $privateHash = 'e249c439ed7697df2a4b045d97d4b9b7e1854c3ff8dd668c779013653913572e'; $content = json_encode(array('test' => 'content')); //$this->app->setPublicHash('3441df0babc2a2dda551d7cd39fb235bc4e09cd1e4556bf261bb49188f548348'); // //print_r("------public hash---------".$this->app->getPublicHash()."------public hash---------"); /*$hash = hash_hmac('sha256', $content, $privateHash); $headers = array( 'X-Public: '.$publicHash, 'X-Hash: '.$hash ); //ob_flush(); $ch = curl_init('http://localhost/slim_redirect_test/index.php/redirected_path'); curl_setopt($ch,CURLOPT_HTTPHEADER,$headers); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_POSTFIELDS,$content); $result = curl_exec($ch); curl_close($ch);*/ //ob_end_flush(); /*ob_end_clean(); $newURL = 'http://localhost/slim_redirect_test/index.php/redirected_path'; header("Location: {$newURL}");*/ } $validator = new \Zend\Validator\Barcode('EAN13'); $floatValidator = new \Zend\I18n\Validator\IsFloat(); if ($floatValidator->isValid(5.3)) { //print_r ("--float test edildi onaylandı---"); $intValidator = new \Zend\I18n\Validator\IsInt(); } $intValidator->setMessage("test validation"); if ($intValidator->isValid(5)) { //print_r ("--int test edildi onaylandı---"); $validator = new \Zend\Validator\StringLength(); } $validator->setMax(6); $validator->isValid("Test"); // returns true $validator->isValid("Testing"); // returns false /*print_r($validator->isValid("Test")); print_r("fffffffffffffffffffff---- "); print_r($validator->isValid("Testing"));*/ if (!$validator->isValid("Testing")) { //print_r("---is not valid----"); $logger = new \Zend\Log\Logger(); } $writer = new \Zend\Log\Writer\Stream('php://output'); /*$logger->addWriter($writer); $logger->log(\Zend\Log\Logger::INFO, 'Informational message'); $this->app->log->debug("test loggg");*/ $this->next->call(); //$this->save(); }