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


PHP Inflector::classify方法代码示例

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


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

示例1: postBuild

 /**
  * Execute after types are built.
  */
 public function postBuild()
 {
     $types_build_path = $this->getBuildPath() ? "{$this->getBuildPath()}/types.php" : null;
     if ($types_build_path) {
         $result = [];
         $result[] = '<?php';
         $result[] = '';
         if ($this->getStructure()->getConfig('header_comment')) {
             $result = array_merge($result, explode("\n", $this->getStructure()->getConfig('header_comment')));
             $result[] = '';
         }
         $namespace = $this->getStructure()->getNamespace();
         if ($namespace) {
             $namespace = ltrim($namespace, '\\');
         }
         if ($this->getStructure()->getNamespace()) {
             $result[] = '/**';
             $result[] = ' * @package ' . $this->getStructure()->getNamespace();
             $result[] = ' */';
         }
         $result[] = 'return [';
         foreach ($this->getStructure()->getTypes() as $current_type) {
             $result[] = '    ' . var_export($namespace . '\\' . Inflector::classify(Inflector::singularize($current_type->getName())), true) . ',';
         }
         $result[] = '];';
         $result[] = '';
         $result = implode("\n", $result);
         if (is_file($types_build_path) && file_get_contents($types_build_path) === $result) {
             return;
         } else {
             file_put_contents($types_build_path, $result);
             $this->triggerEvent('on_types_built', [$types_build_path]);
         }
     }
 }
开发者ID:activecollab,项目名称:databasestructure,代码行数:38,代码来源:TypesBuilder.php

示例2: camelize

 /**
  * {@inheritdoc}
  */
 public function camelize($str)
 {
     if (isset($this->rules['camelize'][$str])) {
         return $this->rules['camelize'][$str];
     }
     return DoctrineInflector::classify($str);
 }
开发者ID:Viacomino,项目名称:sutra,代码行数:10,代码来源:Grammar.php

示例3: validate

 public function validate(Request $request, array $rules)
 {
     $valid = true;
     foreach ($rules as $field => $rule) {
         if (is_null($rule) || !is_string($rule) || strlen($rule) == 0) {
             throw new ValidationException("Rule must be a string");
         }
         // get field value
         $value = $request->input($field);
         // split validation rule into required / sometimes (no validation if not set or empty)
         // contract and contract parameters
         $parts = explode("|", $rule);
         if (is_null($parts) || !is_array($parts) || count($parts) < 3) {
             throw new ValidationException("Invalid rule");
         }
         $required = strtolower($parts[0]) == "required" ? true : false;
         if ($required && is_null($value)) {
             $valid = false;
             continue;
         }
         $args = explode(":", $parts[1]);
         $clazz = Inflector::classify($args[0]) . "Contract";
         if (!class_exists($clazz)) {
             throw new ValidationException("Invalid rule: invalid validation class '{$clazz}'");
         }
         $instance = new $clazz($value, isset($args[1]) ? $args[1] : array());
         if (!$instance instanceof Contract) {
             throw new ValidationException("Invalid rule: invalid validation class '{$clazz}'. Class must extend Simplified\\Validator\\Contract");
         }
         if (!$instance->isValid()) {
             $valid = false;
         }
     }
     return $valid;
 }
开发者ID:simplified-framework,项目名称:validator,代码行数:35,代码来源:Validator.php

示例4: process

 /**
  * {@inheritDoc}
  */
 public function process(ContainerBuilder $container)
 {
     if (!$container->hasDefinition(self::SERVICE_KEY)) {
         return;
     }
     // find providers
     $providers = [];
     $taggedServices = $container->findTaggedServiceIds(self::TAG);
     foreach ($taggedServices as $id => $attributes) {
         if (empty($attributes[0]['scope'])) {
             throw new InvalidConfigurationException(sprintf('Tag attribute "scope" is required for "%s" service', $id));
         }
         $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
         $scope = $attributes[0]['scope'];
         $providers[$scope][$priority][] = new Reference($id);
     }
     if (empty($providers)) {
         return;
     }
     // add to chain
     $serviceDef = $container->getDefinition(self::SERVICE_KEY);
     foreach ($providers as $scope => $items) {
         // sort by priority and flatten
         krsort($items);
         $items = call_user_func_array('array_merge', $items);
         // register
         foreach ($items as $provider) {
             $serviceDef->addMethodCall(sprintf('add%sVariablesProvider', Inflector::classify($scope)), [$provider]);
         }
     }
 }
开发者ID:ramunasd,项目名称:platform,代码行数:34,代码来源:EmailTemplateVariablesPass.php

示例5: getParametersFromObject

 /**
  * @param $keys
  * @param $object
  * @return array
  */
 protected function getParametersFromObject($keys, $object)
 {
     $parameters = [];
     foreach ($keys as $key) {
         $relation = $object;
         $method = 'get' . Inflector::classify($key);
         if (method_exists($relation, $method)) {
             $relation = $relation->{$method}();
         } else {
             $segments = explode('_', $key);
             if (count($segments) > 1) {
                 foreach ($segments as $segment) {
                     $method = 'get' . Inflector::classify($segment);
                     if (method_exists($relation, $method)) {
                         $relation = $relation->{$method}();
                     } else {
                         $relation = $object;
                         break;
                     }
                 }
             }
         }
         if ($object !== $relation) {
             $parameters[$key] = $relation;
         }
     }
     return $parameters;
 }
开发者ID:piotrminkina,项目名称:routing-bundle,代码行数:33,代码来源:UrlGenerator.php

示例6: buildType

 /**
  * @param TypeInterface $type
  */
 public function buildType(TypeInterface $type)
 {
     $class_name = Inflector::classify(Inflector::singularize($type->getName()));
     $base_class_name = 'Base\\' . $class_name;
     $class_build_path = $this->getBuildPath() ? "{$this->getBuildPath()}/{$class_name}.php" : null;
     if ($class_build_path && is_file($class_build_path)) {
         $this->triggerEvent('on_class_build_skipped', [$class_name, $class_build_path]);
         return;
     }
     $result = [];
     $result[] = '<?php';
     $result[] = '';
     if ($this->getStructure()->getConfig('header_comment')) {
         $result = array_merge($result, explode("\n", $this->getStructure()->getConfig('header_comment')));
         $result[] = '';
     }
     if ($this->getStructure()->getNamespace()) {
         $result[] = 'namespace ' . $this->getStructure()->getNamespace() . ';';
         $result[] = '';
         $result[] = '/**';
         $result[] = ' * @package ' . $this->getStructure()->getNamespace();
         $result[] = ' */';
     }
     $result[] = 'class ' . $class_name . ' extends ' . $base_class_name;
     $result[] = '{';
     $result[] = '}';
     $result[] = '';
     $result = implode("\n", $result);
     if ($this->getBuildPath()) {
         file_put_contents($class_build_path, $result);
     } else {
         eval(ltrim($result, '<?php'));
     }
     $this->triggerEvent('on_class_built', [$class_name, $class_build_path]);
 }
开发者ID:activecollab,项目名称:databasestructure,代码行数:38,代码来源:TypeClassBuilder.php

示例7: __call

 /**
  * Catch all getter and setter
  *
  * @param  string $name
  * @param  array $arguments
  *
  * @return mixed
  */
 public function __call($name, $arguments)
 {
     // Match the getters
     if (substr($name, 0, 3) == 'get') {
         $parameter = Inflector::tableize(substr($name, 3));
         if (property_exists($this, $parameter)) {
             return $this->{$parameter};
         } else {
             throw new \Exception(sprintf('The property "%s" does not exist.', $parameter));
         }
     }
     // Match the setters
     if (substr($name, 0, 3) == 'set') {
         $parameter = Inflector::tableize(substr($name, 3));
         $method = 'set' . Inflector::classify($parameter);
         if (method_exists($this, $method)) {
             return $this->{$method}($arguments[0]);
         } else {
             if (property_exists($this, $parameter) && isset($arguments[0])) {
                 $this->{$parameter} = $arguments[0];
                 return $this;
             } else {
                 throw new \Exception(sprintf('The property "%s" does not exist.', $parameter));
             }
         }
     }
 }
开发者ID:mailingreport,项目名称:mailingreport-php,代码行数:35,代码来源:BaseModel.php

示例8: getDirection

 /**
  * {@inheritdoc}
  */
 public function getDirection($activity, $target)
 {
     //check if target is entity created from admin part
     if (!$target instanceof EmailHolderInterface) {
         $metadata = $this->doctrineHelper->getEntityMetadata($target);
         $columns = $metadata->getColumnNames();
         $className = get_class($target);
         foreach ($columns as $column) {
             //check only columns with 'contact_information'
             if ($this->isEmailType($className, $column)) {
                 $getMethodName = "get" . Inflector::classify($column);
                 /** @var $activity Email */
                 if ($activity->getFromEmailAddress()->getEmail() === $target->{$getMethodName}()) {
                     return DirectionProviderInterface::DIRECTION_OUTGOING;
                 } else {
                     foreach ($activity->getTo() as $recipient) {
                         if ($recipient->getEmailAddress()->getEmail() === $target->{$getMethodName}()) {
                             return DirectionProviderInterface::DIRECTION_INCOMING;
                         }
                     }
                 }
             }
         }
         return DirectionProviderInterface::DIRECTION_UNKNOWN;
     }
     /** @var $activity Email */
     /** @var $target EmailHolderInterface */
     if ($activity->getFromEmailAddress()->getEmail() === $target->getEmail()) {
         return DirectionProviderInterface::DIRECTION_OUTGOING;
     }
     return DirectionProviderInterface::DIRECTION_INCOMING;
 }
开发者ID:antrampa,项目名称:crm,代码行数:35,代码来源:EmailDirectionProvider.php

示例9: reverseTransform

 /**
  * @param Request $request
  * @param string $id
  * @param string $type
  * @param string $event
  * @param string $eventClass
  *
  * @return Response
  */
 protected function reverseTransform(Request $request, $id, $type, $event, $eventClass)
 {
     $facadeName = Inflector::classify($type) . 'Facade';
     $typeName = Inflector::tableize($type);
     $format = $request->get('_format', 'json');
     $facade = $this->get('jms_serializer')->deserialize($request->getContent(), 'OpenOrchestra\\ApiBundle\\Facade\\' . $facadeName, $format);
     $mixed = $this->get('open_orchestra_model.repository.' . $typeName)->find($id);
     $oldStatus = null;
     if ($mixed instanceof StatusableInterface) {
         $oldStatus = $mixed->getStatus();
     }
     $mixed = $this->get('open_orchestra_api.transformer_manager')->get($typeName)->reverseTransform($facade, $mixed);
     if ($this->isValid($mixed)) {
         $em = $this->get('object_manager');
         $em->persist($mixed);
         $em->flush();
         if (in_array('OpenOrchestra\\ModelInterface\\Event\\EventTrait\\EventStatusableInterface', class_implements($eventClass))) {
             $this->dispatchEvent($event, new $eventClass($mixed, $oldStatus));
             return array();
         }
         $this->dispatchEvent($event, new $eventClass($mixed));
         return array();
     }
     return $this->getViolations();
 }
开发者ID:open-orchestra,项目名称:open-orchestra-base-api-bundle,代码行数:34,代码来源:BaseController.php

示例10: addTest

 public function addTest($testName)
 {
     $methodName = 'test' . Inflector::classify($testName);
     $testMethod = new ClassMethod($methodName, array(), array());
     $testMethod->setScope('public');
     $this->methods[] = $testMethod;
     return $testMethod;
 }
开发者ID:Ronmi,项目名称:CodeGen,代码行数:8,代码来源:PHPUnitFrameworkTestCase.php

示例11: create

 /**
  * Create platform function node.
  *
  * @param string $platformName
  * @param string $functionName
  * @param array $parameters
  * @throws \Doctrine\ORM\Query\QueryException
  * @return PlatformFunctionNode
  */
 public static function create($platformName, $functionName, array $parameters)
 {
     $className = __NAMESPACE__ . '\\Platform\\Functions\\' . Inflector::classify(strtolower($platformName)) . '\\' . Inflector::classify(strtolower($functionName));
     if (!class_exists($className)) {
         throw QueryException::syntaxError(sprintf('Function "%s" does not supported for platform "%s"', $functionName, $platformName));
     }
     return new $className($parameters);
 }
开发者ID:Hikariii,项目名称:doctrine-extensions,代码行数:17,代码来源:FunctionFactory.php

示例12: parseResult

 /**
  * Parse a response body into a collection
  *
  * @param  string $data
  *
  * @return ResultCollection
  */
 public static function parseResult($data)
 {
     $responseBody = json_decode($data, true);
     $rootKey = self::getRootKey($responseBody);
     $data = self::getResultForRootKey($responseBody, $rootKey);
     $className = Inflector::classify($rootKey);
     $result = new Result();
     return $result->fromArrayWithObject($data, $className);
 }
开发者ID:mailingreport,项目名称:mailingreport-php,代码行数:16,代码来源:Response.php

示例13: instantiate

 public function instantiate(string $class, array $data)
 {
     $object = new $class();
     foreach ($data as $key => $value) {
         $method = 'set' . Inflector::classify($key);
         $object->{$method}($value);
     }
     return $object;
 }
开发者ID:ferodss,项目名称:input,代码行数:9,代码来源:SetInstantiator.php

示例14: getHandler

 public function getHandler($alias)
 {
     $className = Inflector::classify($alias);
     $handlerClass = sprintf('\\%s\\%sHandler', $this->handlerNamespace, $className);
     if (!class_exists($handlerClass)) {
         throw new \RuntimeException('The specified handler class does not exist: ' . $handlerClass);
     }
     return new $handlerClass($this->typeHandler);
 }
开发者ID:code-community,项目名称:input,代码行数:9,代码来源:Factory.php

示例15: getActionClassFromControllerName

 /**
  * @param string $controller
  * @return string
  */
 public static function getActionClassFromControllerName($controller)
 {
     $actionNameStart = strpos($controller, ':') + 1;
     $actionNameLength = strrpos($controller, 'Action') - $actionNameStart;
     $actionName = substr($controller, $actionNameStart, $actionNameLength);
     $actionName = Inflector::classify($actionName);
     $refl = new \ReflectionClass(Action::class);
     return $refl->getNamespaceName() . '\\' . $actionName;
 }
开发者ID:bitecodes,项目名称:rest-api-generator-bundle,代码行数:13,代码来源:ApiHelper.php


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