1: <?php
 2: 
 3: /**
 4:  * Support functions for RedBeanPHP.
 5:  * Additional convenience shortcut functions for RedBeanPHP.
 6:  *
 7:  * @file    RedBeanPHP/Functions.php
 8:  * @author  Gabor de Mooij and the RedBeanPHP community
 9:  * @license BSD/GPLv2
10:  *
11:  * @copyright
12:  * copyright (c) G.J.G.T. (Gabor) de Mooij and the RedBeanPHP Community.
13:  * This source file is subject to the BSD/GPLv2 License that is bundled
14:  * with this source code in the file license.txt.
15:  */
16: 
17: /**
18:  * Convenience function for ENUM short syntax in queries.
19:  *
20:  * Usage:
21:  *
22:  * <code>
23:  * R::find( 'paint', ' color_id = ? ', [ EID('color:yellow') ] );
24:  * </code>
25:  *
26:  * If a function called EID() already exists you'll have to write this
27:  * wrapper yourself ;)
28:  *
29:  * @param string $enumName enum code as you would pass to R::enum()
30:  *
31:  * @return mixed
32:  */
33: if (!function_exists('EID')) {
34: 
35:     function EID($enumName)
36:     {
37:         return \RedBeanPHP\Facade::enum( $enumName )->id;
38:     }
39: 
40: }
41: 
42: /**
43:  * Prints the result of R::dump() to the screen using
44:  * print_r.
45:  *
46:  * @param mixed $data data to dump
47:  *
48:  * @return void
49:  */
50: if ( !function_exists( 'dump' ) ) {
51: 
52:     function dmp( $list )
53:     {
54:         print_r( \RedBeanPHP\Facade::dump( $list ) );
55:     }
56: }
57: 
58: /**
59:  * Function alias for R::genSlots().
60:  */
61: if ( !function_exists( 'genslots' ) ) {
62: 
63:     function genslots( $slots, $tpl = NULL )
64:     {
65:         return \RedBeanPHP\Facade::genSlots( $slots, $tpl );
66:     }
67: }
68: 
69: /**
70:  * Function alias for R::flat().
71:  */
72: if ( !function_exists( 'array_flatten' ) ) {
73: 
74:     function array_flatten( $array )
75:     {
76:         return \RedBeanPHP\Facade::flat( $array );
77:     }
78: }
79: