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


PHP Configuration::addCustomDatetimeFunction方法代码示例

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


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

示例1: testAddGetCustomDatetimeFunction

 public function testAddGetCustomDatetimeFunction()
 {
     $this->configuration->addCustomDatetimeFunction('FunctionName', __CLASS__);
     $this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('FunctionName'));
     $this->assertSame(null, $this->configuration->getCustomDatetimeFunction('NonExistingFunction'));
     $this->configuration->setCustomDatetimeFunctions(array('OtherFunctionName' => __CLASS__));
     $this->assertSame(__CLASS__, $this->configuration->getCustomDatetimeFunction('OtherFunctionName'));
     $this->setExpectedException('Doctrine\\ORM\\ORMException');
     $this->configuration->addCustomDatetimeFunction('date_add', __CLASS__);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:10,代码来源:ConfigurationTest.php

示例2: registerDqlFunction

 /**
  * @param string $type
  * @param string $functionName
  * @param string $functionClass
  * @param Configuration $configuration
  */
 protected function registerDqlFunction($type, $functionName, $functionClass, Configuration $configuration)
 {
     switch ($type) {
         case 'datetime':
             $configuration->addCustomDatetimeFunction($functionName, $functionClass);
             break;
         case 'numeric':
             $configuration->addCustomNumericFunction($functionName, $functionClass);
             break;
         case 'string':
         default:
             $configuration->addCustomStringFunction($functionName, $functionClass);
     }
 }
开发者ID:sergeypererva,项目名称:doctrine-extensions,代码行数:20,代码来源:FunctionsTest.php

示例3: load

 /**
  * @param Configuration $configuration
  * @param string        $database
  */
 public static function load(Configuration $configuration, $database)
 {
     $parser = new Parser();
     // Load the corresponding config file.
     $config = $parser->parse(file_get_contents(realpath(__DIR__ . '/../../config/' . $database . '.yml')));
     $parsed = $config['doctrine']['orm']['dql'];
     // Load the existing function classes.
     if (array_key_exists('datetime_functions', $parsed)) {
         foreach ($parsed['datetime_functions'] as $key => $value) {
             $configuration->addCustomDatetimeFunction(strtoupper($key), $value);
         }
     }
     if (array_key_exists('numeric_functions', $parsed)) {
         foreach ($parsed['numeric_functions'] as $key => $value) {
             $configuration->addCustomNumericFunction(strtoupper($key), $value);
         }
     }
     if (array_key_exists('string_functions', $parsed)) {
         foreach ($parsed['string_functions'] as $key => $value) {
             $configuration->addCustomStringFunction(strtoupper($key), $value);
         }
     }
 }
开发者ID:beberlei,项目名称:DoctrineExtensions,代码行数:27,代码来源:ConfigLoader.php

示例4: addCustomFunctions

 /**
  * Adds userdefined functions.
  *
  * @param  Configuration $config
  * @param  array         $options
  * @return Configuration
  */
 private static function addCustomFunctions(Configuration $config, array $options = array())
 {
     if (null !== ($strFcts = Collection::get($options, 'orm:entity_managers:default:dql:string_functions'))) {
         foreach ($strFcts as $name => $class) {
             if (class_exists($class)) {
                 $config->addCustomStringFunction($name, $class);
             }
         }
     }
     if (null !== ($numFcts = Collection::get($options, 'orm:entity_managers:default:dql:numeric_functions'))) {
         foreach ($numFcts as $name => $class) {
             if (class_exists($class)) {
                 $config->addCustomNumericFunction($name, $class);
             }
         }
     }
     if (null !== ($datetimeFcts = Collection::get($options, 'orm:entity_managers:default:dql:datetime_functions'))) {
         foreach ($datetimeFcts as $name => $class) {
             if (class_exists($class)) {
                 $config->addCustomDatetimeFunction($name, $class);
             }
         }
     }
     return $config;
 }
开发者ID:mickaelsteinberg,项目名称:BackBee,代码行数:32,代码来源:EntityManagerCreator.php

示例5: setupCustomFunctions

 protected function setupCustomFunctions(Configuration $config, $spec)
 {
     foreach ($spec['custom_hydration_modes'] as $name => $classname) {
         $config->addCustomHydrationMode($name, $classname);
     }
     foreach ($spec['custom_datetime_functions'] as $name => $classname) {
         $config->addCustomDatetimeFunction($name, $classname);
     }
     foreach ($spec['custom_numeric_functions'] as $name => $classname) {
         $config->addCustomNumericFunction($name, $classname);
     }
     foreach ($spec['custom_string_functions'] as $name => $classname) {
         $config->addCustomStringFunction($name, $classname);
     }
     foreach ($spec['filters'] as $name => $classname) {
         $config->addFilter($name, $classname);
     }
 }
开发者ID:radnan,项目名称:rdn-doctrine,代码行数:18,代码来源:EntityManagerLoader.php


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