本文整理汇总了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__);
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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);
}
}