Skip to content

Commit

Permalink
kernel can give all updated config
Browse files Browse the repository at this point in the history
  • Loading branch information
den-dev committed Nov 24, 2015
1 parent 5ca8057 commit d10cbee
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
10 changes: 10 additions & 0 deletions src/Adaptability.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ public function get_config_value( $config_name, $default_value = false )
return $this->_krl->get_config_value( $config_name, $default_value );
}

/**
* Retourne toute la configuration.
*
* @return array tableau ou tableau de tableau de config
*/
public function get_config_values( $service_name = false )
{
return $this->_krl->get_config_values( $service_name );
}

/**
* Ecriture de log basique ou via service du kernel
*
Expand Down
11 changes: 11 additions & 0 deletions src/AdaptabilityInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,15 @@ public function set_service_metas();
* @return object instance du service
*/
public function get_service_instance();

/**
* Donne la configuration complete du service
*
* Ou la configuration complete de tout les services
*
* @param string $service_name nom du service ou false
*
* @return array tableau associatif de configuration
*/
public function get_config_values( $service_name = false );
}
22 changes: 18 additions & 4 deletions src/NoKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,20 @@ public function get_config_value( $config_name, $default_value = false )
return $value;
}

/**
* Retourne toute la configuration.
*
* Renvoi toute la config d'un service ou de tout les services
*
* @param string $service_name le nom du service dont on veut tout
*
* @return array tableau ou tableau de tableau de config
*/
public function get_config_values( $service_name = false ) // pour etre identique a Kernel
{
return $this->_configs;
}

/**
* Ecriture de log basique.
*
Expand All @@ -84,17 +98,17 @@ public function log( $service_name, $log_name, $level, $message, $context = arra
{
mkdir( $log_path, 0755 );
}

$log_path .= $log_name . ".log";

// avoid big file
$append = false;
if( file_exists( $log_path ) && filesize( $log_path ) >= 1024 )
{
// unlink( $log_path );
// unlink( $log_path );
$append = FILE_APPEND;
}

// write
$context_string = ( (bool) $context ) ? print_r( $context, true ) : '';
$formated_message = $level . ': ' . $message . ' ( ' . $context_string . ' )';
Expand Down Expand Up @@ -125,7 +139,7 @@ public function error( $service_name, $message, $code, $context = false, $fatal

$context_string = ( (bool) $context ) ? print_r( $context, true ) : '';
$formated_message = $level . ': ' . $message . ' ( ' . $context_string . ' )';

$ok = $this->log( $service_name, 'error', $level, $formated_message, $context_string );

// error
Expand Down

0 comments on commit d10cbee

Please sign in to comment.