library/Garp/Model/Behavior/Videoable.php
protected function _beforeSave(&$args, $event) {
        $data = &$args[1];
        if (!empty($data['url'])) {
            $url = $data['url'];
            if ($this->_isYouTubeUrl($url)) {
                // check for YouTube
                $behavior = new Garp_Model_Behavior_YouTubeable($this->_config['youtube']);
                $data['type'] = 'youtube';
            } elseif ($this->_isVimeoUrl($url)) {
                // check for Vimeo
                $behavior = new Garp_Model_Behavior_Vimeoable($this->_config['vimeo']);
                $data['type'] = 'vimeo';
            } else {
                $error = sprintf(self::ERROR_INVALID_VIDEO_URL, $url);
                throw new Garp_Model_Behavior_Videoable_Exception_InvalidUrl($error);
            }
            $behavior->{$event}($args);
        }
    }
protected function _beforeSave(&$args, $event) {
        $data = &$args[1];
        if (!empty($data['url'])) {
            $url = $data['url'];
            if ($this->_isYouTubeUrl($url)) {
                // check for YouTube
                $behavior = new Garp_Model_Behavior_YouTubeable($this->_config['youtube']);
                $data['type'] = 'youtube';
            } elseif ($this->_isVimeoUrl($url)) {
                // check for Vimeo
                $behavior = new Garp_Model_Behavior_Vimeoable($this->_config['vimeo']);
                $data['type'] = 'vimeo';
            } else {
                $error = sprintf(self::ERROR_INVALID_VIDEO_URL, $url);
                throw new Garp_Model_Behavior_Videoable_Exception_InvalidUrl($error);
            }
            $behavior->{$event}($args);
        }
    }
protected function _beforeSave ( & $ args , $ event ) { $ data = & $ args [ 1 ] ; if ( ! empty ( $ data [ 'url' ] ) ) { $ url = $ data [ 'url' ] ; if ( $ this -> _isYouTubeUrl ( $ url ) ) { // check for YouTube $ behavior = new Garp_Model_Behavior_YouTubeable ( $ this -> _config [ 'youtube' ] ) ; $ data [ 'type' ] = 'youtube' ; } elseif ( $ this -> _isVimeoUrl ( $ url ) ) { // check for Vimeo $ behavior = new Garp_Model_Behavior_Vimeoable ( $ this -> _config [ 'vimeo' ] ) ; $ data [ 'type' ] = 'vimeo' ; } else { $ error = sprintf ( self :: ERROR_INVALID_VIDEO_URL , $ url ) ; throw new Garp_Model_Behavior_Videoable_Exception_InvalidUrl ( $ error ) ; } $ behavior -> { $ event } ( $ args ) ; } }
Custom callback for both insert and update
@param Array $args
@param String $event
@return Void
Custom callback for both insert and update