Skip to content

Commit

Permalink
[ZendBundle] added an option to register zend logger as an error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
noelg authored and fabpot committed Aug 30, 2010
1 parent e4b3d7c commit d40d174
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Symfony/Bundle/ZendBundle/DependencyInjection/ZendExtension.php 100644 → 100755
Expand Up @@ -52,6 +52,16 @@ public function loggerLoad($config, ContainerBuilder $container)
if (isset($config['path'])) {
$container->setParameter('zend.logger.path', $config['path']);
}

if (isset($config['log_errors'])) {
$definition = $container->findDefinition('zend.logger');
if (false === $config['log_errors'] && $definition->hasMethodCall('registerErrorHandler')) {
$container->findDefinition('zend.logger')->removeMethodCall('registerErrorHandler');
}
else {
$container->findDefinition('zend.logger')->addMethodCall('registerErrorHandler');
}
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Symfony/Bundle/ZendBundle/Resources/config/logger.xml 100644 → 100755
Expand Up @@ -7,6 +7,7 @@
<parameters>
<parameter key="zend.logger.class">Symfony\Bundle\ZendBundle\Logger\Logger</parameter>
<parameter key="zend.logger.priority" type="constant">Zend\Log\Logger::CRIT</parameter>
<parameter key="zend.logger.log_errors">true</parameter>
<parameter key="zend.logger.writer.debug.class">Symfony\Bundle\ZendBundle\Logger\DebugLogger</parameter>
<parameter key="zend.logger.writer.filesystem.class">Zend\Log\Writer\Stream</parameter>
<parameter key="zend.formatter.filesystem.class">Zend\Log\Formatter\Simple</parameter>
Expand Down
37 changes: 37 additions & 0 deletions src/Symfony/Component/DependencyInjection/Definition.php 100644 → 100755
Expand Up @@ -185,6 +185,43 @@ public function addMethodCall($method, array $arguments = array())
return $this;
}

/**
* Removes a method to call after service initialization.
*
* @param string $method The method name to remove
*
* @return Definition The current instance
*/
public function removeMethodCall($method)
{
foreach ($this->calls as $i => $call) {
if ($call[0] === $method) {
unset($this->calls[$i]);
break;
}
}

return $this;
}

/**
* Check if the current definition has a given method to call after service initialization.
*
* @param string $method The method name to search for
*
* @return boolean
*/
public function hasMethodCall($method)
{
foreach ($this->calls as $i => $call) {
if ($call[0] === $method) {
return true;
}
}

return false;
}

/**
* Gets the methods to call after service initialization.
*
Expand Down

0 comments on commit d40d174

Please sign in to comment.