partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit b45da46b35d0ba2558952f9d6c7036abae7dd420
parent ab8c4ec2c2734d61b8cc76a4a0935aa398de5953
Author: felicitus <felicitus@felicitus.org>
Date:   Tue, 27 Dec 2011 17:40:52 +0100

Added check for the DoctrineSymfonyYaml package, fixes #141

Diffstat:
Msrc/backend/de/RaumZeitLabor/PartKeepr/Setup/Setup.php | 6+-----
Msrc/setup/setup.php | 4----
Msrc/setup/tests/check-doctrine.php | 61+++++++++++++++++++++++++++++++++++++++++++++++++++++++------
3 files changed, 56 insertions(+), 15 deletions(-)

diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Setup/Setup.php b/src/backend/de/RaumZeitLabor/PartKeepr/Setup/Setup.php @@ -116,11 +116,7 @@ class Setup { * @return array The parsed YAML file */ public static function loadYAML ($file) { - if (method_exists("\Symfony\Component\Yaml\Yaml", "load")) { - return \Symfony\Component\Yaml\Yaml::load($file); - } else { - return \Symfony\Component\Yaml\Yaml::parse($file); - } + return \Symfony\Component\Yaml\Yaml::parse($file); } /** diff --git a/src/setup/setup.php b/src/setup/setup.php @@ -6,10 +6,6 @@ declare(encoding = 'UTF-8'); use de\RaumZeitLabor\PartKeepr\PartKeepr, de\RaumZeitLabor\PartKeepr\Setup\Setup; -/*function exception_error_handler($errno, $errstr, $errfile, $errline ) { - throw new ErrorException($errstr, $errno, 0, $errfile, $errline); -} -set_error_handler("errorHandler", E_ALL);*/ set_error_handler(create_function('$a, $b, $c, $d', 'throw new ErrorException($b, 0, $a, $c, $d);'), E_ALL); diff --git a/src/setup/tests/check-doctrine.php b/src/setup/tests/check-doctrine.php @@ -1,25 +1,74 @@ <?php -@include_once 'Doctrine/Common/ClassLoader.php'; +include_once 'Doctrine/Common/ClassLoader.php'; -$installDoctrineError = "Doctrine needs to be installed and in the PHP include_path. You can install doctrine on most unix systems using: <br/><br/><code>pear channel-discover pear.doctrine-project.org<br/>pear install pear.doctrine-project.org/DoctrineORM</code>"; +/** + * Check if the Doctrine Common classloader can be loaded + */ +$installDoctrineError = "Doctrine needs to be installed and in the PHP include_path. "; +$installDoctrineError .= "You can install doctrine on most unix systems using: <br/>"; +$installDoctrineError .= "<br/><code>pear channel-discover pear.doctrine-project.org<br/>"; +$installDoctrineError .= "pear install pear.doctrine-project.org/DoctrineORM</code><br/>"; if (!class_exists("\\Doctrine\\Common\ClassLoader")) { + $installDoctrineError .= "<small>Doctrine\\Common\\ClassLoader was not found</small>"; echo json_encode(array("error" => true, "errormessage" => $installDoctrineError)); exit; } +/** + * Register the DoctrineORM classloader + */ use Doctrine\Common\ClassLoader; -$classLoader = new ClassLoader('Doctrine\ORM'); -$classLoader->register(); // register on SPL autoload stack -if (!$classLoader->canLoadClass("Doctrine\\ORM\\Version")) { +$ormClassLoader = new ClassLoader('Doctrine\ORM'); +$ormClassLoader->register(); + +$commonClassLoader = new ClassLoader('Doctrine\Common'); +$commonClassLoader->register(); + +$sfClassLoader = new ClassLoader('Symfony'); +$sfClassLoader->register(); + +$doctrineClassLoader = new ClassLoader('Doctrine'); +$doctrineClassLoader->register(); + + +/** + * Check if we can load the Doctrine\ORM\Version class. If we can't load the class, then something is wrong; + * the most likely cause is that the user has DoctrineCommon installed, but is missing DoctrineORM. + */ +if (!$ormClassLoader->canLoadClass("Doctrine\\ORM\\Version")) { + $installDoctrineError .= "<small>The classloader can't load Doctrine\\ORM\\Version</small>"; echo json_encode(array("error" => true, "errormessage" => $installDoctrineError)); exit; } +/** + * Check for the correct DoctrineORM version. We only support Doctrine 2.1.0 or higher. + */ if (\Doctrine\ORM\Version::compare("2.1.0") == 1) { - echo json_encode(array("error" => true, "errormessage" => "DoctrineORM is installed, but needs to be at Version 2.1.0 or higher. Please run pear upgrade-all to bring your packages up-to-date.")); + $versionInvalidMessage = "DoctrineORM is installed, but needs to be at Version 2.1.0 or higher. "; + $versionInvalidMessage .= "Please run pear upgrade-all to bring your packages up-to-date."; + + echo json_encode(array("error" => true, "errormessage" => $versionInvalidMessage)); exit; } + +/** + * Check for the Symfony YAML component. This component is required to parse YAML files and is used during installation + * of footprints. + */ + +if (!$sfClassLoader->canLoadClass("Symfony\\Component\\Yaml\\Yaml") || + !$doctrineClassLoader->canLoadClass("Doctrine\\Symfony\\Component\\Yaml\\Yaml")) { + + $yamlErrorMessage = "The YAML component of symfony is not installed. This component is required; please install "; + $yamlErrorMessage .= "it using:<br/><br/>"; + $yamlErrorMessage .= "<code>pear install pear.doctrine-project.org/DoctrineSymfonyYaml</code>"; + + echo json_encode(array("error" => true, "errormessage" => $yamlErrorMessage)); + exit; +} + echo json_encode(array("error" => false)); exit;