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