/** * Provides a magic factory method to instantiate new objects with * shorter syntax than would otherwise be required by the Zend Framework * naming conventions. For more information, see Zend_Gdata_App::__call(). * * This overrides the default behavior of __call() so that query classes * do not need to have their domain manually set when created with * a magic factory method. * * @see Zend_Gdata_App::__call() * @param string $method The method name being called * @param array $args The arguments passed to the call * @throws Zend_Gdata_App_Exception */ public function __call($method, $args) { if (preg_match('/^new(\\w+Query)/', $method, $matches)) { $class = $matches[1]; $foundClassName = null; foreach ($this->_registeredPackages as $name) { try { // Autoloading disabled on next line for compatibility // with magic factories. See ZF-6660. if (!class_exists($name . '_' . $class, false)) { // require_once 'Zend/Loader.php'; @Zend_Loader::loadClass($name . '_' . $class); } $foundClassName = $name . '_' . $class; break; } catch (Zend_Exception $e) { // package wasn't here- continue searching } } if ($foundClassName != null) { $reflectionObj = new ReflectionClass($foundClassName); // Prepend the domain to the query $args = array_merge(array($this->getDomain()), $args); return $reflectionObj->newInstanceArgs($args); } else { // require_once 'Zend/Gdata/App/Exception.php'; throw new Zend_Gdata_App_Exception("Unable to find '{$class}' in registered packages"); } } else { return parent::__call($method, $args); } }
/** * Provides a magic factory method to instantiate new objects with * shorter syntax than would otherwise be required by the Zend Framework * naming conventions. For more information, see Zend_Gdata_App::__call(). * * This overrides the default behavior of __call() so that query classes * do not need to have their domain manually set when created with * a magic factory method. * * @see Zend_Gdata_App::__call() * @param string $method The method name being called * @param array $args The arguments passed to the call * @throws Zend_Gdata_App_Exception */ public function __call($method, $args) { if (preg_match('/^new(\\w+Query)/', $method, $matches)) { $class = $matches[1]; $foundClassName = null; foreach ($this->_registeredPackages as $name) { try { require_once 'Zend/Loader.php'; @Zend_Loader::loadClass("{$name}_{$class}"); $foundClassName = "{$name}_{$class}"; break; } catch (Zend_Exception $e) { // package wasn't here- continue searching } } if ($foundClassName != null) { $reflectionObj = new ReflectionClass($foundClassName); // Prepend the domain to the query $args = array_merge(array($this->getDomain()), $args); return $reflectionObj->newInstanceArgs($args); } else { require_once 'Zend/Gdata/App/Exception.php'; throw new Zend_Gdata_App_Exception("Unable to find '{$class}' in registered packages"); } } else { return parent::__call($method, $args); } }