fruffl icon

WTF WTF WTF

fruffl | 01/26/13 11:53:55 AM UTC | 0 ⭐ | 280 👁️ | Never ⏰ | []
PHP |

1.06 KB

|

None

|

0 👍

/

0 👎

 
        
        public static function type($type, $content = null, array $options = array())
        {
            $defaults =
            [
                'view'      => false,
                'encode'    => false,
                'decode'    => false,
                'cast'      => true,
                'conditions'    => [],
                'paths'     =>
                [
                    'template'  => '{:lib}/views/{:controller}/{:template}.{:type}.php',
                    'layout'    => '{:lib}/views/layouts/{:layout}.{:type}.php',
                    'element'   => '{:lib}/views/elements/{:template}.{:type}.php'
                ]
            ];
        
            if($content === false)
                unset(static::$__types[$type], static::$__handlers[$type]);
            
            if(!$content && !$options)
            {
                if(!$content = static::__types($type))
                    return;
                
                if(strpos($type, '/'))
                    return $content;
                
                if(is_array($content) && isset($content['alias']))
                    return static::type($content['alias']);
                
                return compact('content') + array('options' => static::handlers($type));
            }
            
            if($content)
                static::$__types[$type] = (array) $content;
            
            static::$__handlers[$type] = $options ? Set::merge($defaults, $options) : [];
        }

Comments