Ticket #67 (enhancement)

Opened 1 year ago

Last modified 1 year ago

make FAL_front.php libraries extensions loading easy

Status: reopened

Reported by: danfreak Assigned to: danfreak
Priority: blocker Milestone: 1.1
Component: software design & optimization Version: 1.0.4
Keywords: Cc:

Add a function that enables FAL_front.php to handle needed classes (Freakauth_light.php and FAL_validation.php) extensions easyly.

SCENARIO: I extend Freakauth_light.php with MyFal?.php class. In FAL_front all references to Freakauth_light.php are hard coded with $this->CI->freakauth_light. Therefore I should replace them all with $this->CI->myfal. The ssame happens specularly with FAL_validation.

Therefore I should dynamically change the reference of $this->CI->freakauth_light from the class in Freakauth_light.php to that in MyFAL.php that extends it.

I should make sure that also the helpers functions get updated.

SOLUTION: config/freakauth_light.php

/*
 |--------------------------------------------------------------------------
 | Enable/Disable FreakAuth light extensions
 |--------------------------------------------------------------------------
 |
 | If you need to extend the Core class (libraries/FreakAuth_light.php) or 
 | the FAL_validation.php class build your files according to the following
 | specifications about file-names. You can place them eaither in system/libraries
 | or in application/libraries
 |
 | - libraries/MyFAL.php
 | - libraries/MyFALVal.php
 | 
 | Following this convention, if $config['FAL_use_extensions'] = TRUE;
 | the above files will be loaded in FAL_front.php, and also the
 | freakauth_light_helper.php functions will be updated.
 | -----------------
 | MyFAL.php EXAMPLE
 | -----------------
 |<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

    class MyFal extends Freakauth_light 
    {
        // -------------------------------------------------------------------- 
        // Class constructor
        // not really needed but I wrote it anyway
        function MyFal()
        {
        	parent::Freakauth_light();
        }
        
        // -------------------------------------------------------------------- 
        // Overwrites normal FAL logout
        function logout()
        {
            log_message('debug', 'MyFAL logout working');
           
            exit('MyFAL logout working');
        }
      }
 |
 */
 $config['FAL_use_extensions'] = TRUE;

FAL_front.php constructor

//let's check if we have extensions, and if we have them
		//let's load them
		    	//do we have an extension for 
    	if ($this->CI->config->item('FAL_use_extensions'))
    	{
    	    $this->_loadExtensions();
    	}
    	else
    	{
    	    log_message('debug', 'FAL not using extensions');
    	}

adding function _loadExtensions() to FAL_front.php

function _loadExtensions()
    {
  
        if (file_exists(APPPATH.'libraries/MyFAL'.EXT) OR file_exists(BASEPATH.'libraries/MyFAL'.EXT))
        {
            //let's load the core library (i.e. FreakAuth_light.php) extension
            $this->CI->load->library('MyFAL');
            
            $this->CI->freakauth_light = new MyFAL();
            log_message('debug', 'MyFAL library loaded');
            log_message('debug', 'MyFAL class assigned to $this->CI->freakauth_light');
        }
        else
        {
            log_message('debug', 'MyFAL class not found');
        }

        if (file_exists(APPPATH.'libraries/MyFALVal'.EXT) OR file_exists(BASEPATH.'libraries/MyFALVal'.EXT))
        {
            //let's load the validation library (i.e. FAL_validation.php) extension
            //and assign it to $this->CI->fal_validation
            $this->CI->load->library('MyFALVal');
            $this->CI->fal_validation = new MyFALVal();

        }
        else
        {
            log_message('debug', 'MyFALVal class not found');
        }
    }

Change History

05/29/07 10:21:36: Modified by danfreak

  • type changed from defect to enhancement.

05/29/07 10:22:11: Modified by danfreak

  • status changed from new to closed.
  • resolution set to fixed.

in [276]

06/15/07 04:56:10: Modified by grahack

  • priority changed from major to blocker.
  • component changed from none to software design & optimization.
  • status changed from closed to reopened.
  • resolution deleted.

you didn't much wait for me for this one

why is it in FAL_front and not in the main lib ?

this seems critical to me in terms of software design

06/27/07 08:23:29: Modified by

  • milestone deleted.

Milestone 1.0.5 deleted

06/27/07 08:25:24: Modified by grahack

  • milestone set to 1.1.