本文整理汇总了PHP中Zend\Loader::loadClass方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::loadClass方法的具体用法?PHP Loader::loadClass怎么用?PHP Loader::loadClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Loader
的用法示例。
在下文中一共展示了Loader::loadClass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
if (!class_exists('Archive_Tar')) {
try {
\Zend\Loader::loadClass('Archive_Tar');
} catch (\Zend\Loader\Exception $e) {
$this->markTestSkipped('This filter needs PEARs Archive_Tar');
}
}
$files = array(dirname(__DIR__) . '/_files/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First/Second/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First/Second', dirname(__DIR__) . '/_files/_compress/Compress/First/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress/First', dirname(__DIR__) . '/_files/_compress/Compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress/Compress', dirname(__DIR__) . '/_files/_compress/zipextracted.txt', dirname(__DIR__) . '/_files/_compress', dirname(__DIR__) . '/_files/compressed.tar');
foreach ($files as $file) {
if (file_exists($file)) {
if (is_dir($file)) {
rmdir($file);
} else {
unlink($file);
}
}
}
if (!file_exists(dirname(__DIR__) . '/_files/Compress/First/Second')) {
mkdir(dirname(__DIR__) . '/_files/Compress/First/Second', 0777, true);
file_put_contents(dirname(__DIR__) . '/_files/Compress/First/Second/zipextracted.txt', 'compress me');
file_put_contents(dirname(__DIR__) . '/_files/Compress/First/zipextracted.txt', 'compress me');
file_put_contents(dirname(__DIR__) . '/_files/Compress/zipextracted.txt', 'compress me');
}
}
示例2: testSelectQueryWithBinds
/**
* ZF-2017: Test bind use of the Zend_Db_Select class.
*/
public function testSelectQueryWithBinds()
{
$select = $this->_select()->where('product_id = :product_id')->bind(array(':product_id' => 1));
$sql = preg_replace('/\\s+/', ' ', $select->__toString());
$this->assertEquals('SELECT "zfproducts".* FROM "zfproducts" WHERE (product_id = :product_id)', $sql);
$stmt = $select->query();
\Zend\Loader::loadClass('Zend_Db_Statement_Static');
$this->assertInstanceOf('Zend_Db_Statement_Static', $stmt);
}
示例3: setAdapter
public function setAdapter($adapter)
{
if (is_string($adapter)) {
$storageAdapterClass = 'Zend\\Tool\\Framework\\Client\\Storage\\' . ucfirst($adapter);
\Zend\Loader::loadClass($storageAdapterClass);
$adapter = new $storageAdapterClass();
}
$this->_adapter = $adapter;
}
示例4: __construct
/**
* Class constructor
*
* @param array $options (Optional) Options to set
*/
public function __construct($options = null)
{
if (!class_exists('Archive_Tar')) {
try {
\Zend\Loader::loadClass('Archive_Tar');
} catch (\Exception $e) {
throw new Exception\ExtensionNotLoadedException('This filter needs PEARs Archive_Tar', 0, $e);
}
}
parent::__construct($options);
}
示例5: addContextClass
public function addContextClass($contextClass)
{
if (!class_exists($contextClass)) {
\Zend\Loader::loadClass($contextClass);
}
$reflectionContextClass = new \ReflectionClass($contextClass);
if ($reflectionContextClass->isInstantiable()) {
$context = new $contextClass();
return $this->addContext($context);
}
return $this;
}
示例6: _getTable
protected function _getTable($tableClass, $options = array())
{
if (is_array($options) && !isset($options['db'])) {
$options['db'] = $this->_db;
}
if (!class_exists($tableClass)) {
$this->_useMyIncludePath();
\Zend\Loader::loadClass($tableClass);
$this->_restoreIncludePath();
}
$table = new $tableClass($options);
return $table;
}
示例7: setAdapter
/**
* Sets a new adapter
*
* @param string $adapter Adapter to use
* @param boolean $direction OPTIONAL False means Download, true means upload
* @param array $options OPTIONAL Options to set for this adapter
* @throws \Zend\File\Transfer\Exception
*/
public function setAdapter($adapter, $direction = false, $options = array())
{
if (\Zend\Loader::isReadable('Zend/File/Transfer/Adapter/' . ucfirst($adapter) . '.php')) {
$adapter = 'Zend\\File\\Transfer\\Adapter\\' . ucfirst($adapter);
}
if (!class_exists($adapter)) {
\Zend\Loader::loadClass($adapter);
}
$direction = (int) $direction;
$this->_adapter[$direction] = new $adapter($options);
if (!$this->_adapter[$direction] instanceof Adapter\AbstractAdapter) {
throw new Transfer\Exception("Adapter " . $adapter . " does not extend Zend_File_Transfer_Adapter_Abstract");
}
return $this;
}
示例8: convertToObject
/**
* Converts a DOMElement object into the specific class
*
* @throws \Zend\InfoCard\XML\Exception
* @param DOMElement $e The DOMElement object to convert
* @param string $classname The name of the class to convert it to (must inhert from \Zend\InfoCard\XML\Element)
* @return \Zend\InfoCard\XML\Element a Xml Element object from the DOM element
*/
public static function convertToObject(\DOMElement $e, $classname)
{
if (!class_exists($classname)) {
\Zend\Loader::loadClass($classname);
}
if (!is_subclass_of($classname, 'Zend\\InfoCard\\XML\\Element')) {
throw new Exception\InvalidArgumentException("DOM element must be converted to an instance of Zend_InfoCard_Xml_Element");
}
$sxe = simplexml_import_dom($e, $classname);
if (!$sxe instanceof Element) {
// Since we just checked to see if this was a subclass of Zend_infoCard_Xml_Element this shoudl never fail
// @codeCoverageIgnoreStart
throw new Exception\RuntimeException("Failed to convert between DOM and SimpleXML");
// @codeCoverageIgnoreEnd
}
return $sxe;
}
示例9: introspect
/**
* Create XML definition on an AMF service class
*
* @param string $serviceClass Service class name
* @param array $options invocation options
* @return string XML with service class introspection
*/
public function introspect($serviceClass, $options = array())
{
$this->_options = $options;
if (strpbrk($serviceClass, '\\/<>')) {
return $this->_returnError('Invalid service name');
}
// Transform com.foo.Bar into com\foo\Bar
$serviceClass = str_replace('.', '\\', $serviceClass);
// Introspect!
if (!class_exists($serviceClass)) {
\Zend\Loader::loadClass($serviceClass, $this->_getServicePath());
}
$serv = $this->_xml->createElement('service-description');
$serv->setAttribute('xmlns', 'http://ns.adobe.com/flex/service-description/2008');
$this->_types = $this->_xml->createElement('types');
$this->_ops = $this->_xml->createElement('operations');
$r = \Zend\Server\Reflection::reflectClass($serviceClass);
$this->_addService($r, $this->_ops);
$serv->appendChild($this->_types);
$serv->appendChild($this->_ops);
$this->_xml->appendChild($serv);
return $this->_xml->saveXML();
}
示例10: setContainerClass
/**
* Set the container class to use
*
* @param string $name
* @return \Zend\View\Helper\Placeholder\Registry\Registry
*/
public function setContainerClass($name)
{
if (!class_exists($name)) {
\Zend\Loader::loadClass($name);
}
//$reflection = new \ReflectionClass($name);
//if (!$reflection->isSubclassOf(new \ReflectionClass('Zend\View\Helper\Placeholder\Container\AbstractContainer'))) {
if (!in_array('Zend\\View\\Helper\\Placeholder\\Container\\AbstractContainer', class_parents($name))) {
$e = new Exception('Invalid Container class specified');
//$e->setView($this->view);
throw $e;
}
$this->_containerClass = $name;
return $this;
}
示例11: _constructFromConfig
/**
* Construct a filter or writer from config
*
* @param string $type 'writer' of 'filter'
* @param mixed $config Config or Array
* @param string $namespace
* @throws Exception\InvalidArgumentException
* @return object
*/
protected function _constructFromConfig($type, $config, $namespace)
{
if ($config instanceof Config) {
$config = $config->toArray();
}
if (!is_array($config) || empty($config)) {
throw new Exception\InvalidArgumentException('Configuration must be an array or instance of Zend\\Config\\Config');
}
$params = isset($config[$type . 'Params']) ? $config[$type . 'Params'] : array();
$className = $this->getClassName($config, $type, $namespace);
if (!class_exists($className)) {
\Zend\Loader::loadClass($className);
}
$reflection = new ReflectionClass($className);
if (!$reflection->implementsInterface('Zend\\Log\\Factory')) {
throw new Exception\InvalidArgumentException($className . ' does not implement Zend\\Log\\Factory and can not be constructed from config.');
}
return $className::factory($params);
}
示例12: _initPlugin
/**
* Initialize front controller plugin
*
* @return void
*/
protected function _initPlugin()
{
$pluginClass = $this->getPluginClass();
$front = Controller\Front::getInstance();
if (!$front->hasPlugin($pluginClass)) {
if (!class_exists($pluginClass)) {
\Zend\Loader::loadClass($pluginClass);
}
$front->registerPlugin(new $pluginClass($this), 99);
}
}
示例13: __call
/**
* 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)) {
@\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 {
throw new App\Exception("Unable to find '{$class}' in registered packages");
}
} else {
return parent::__call($method, $args);
}
}
示例14: prepare
/**
* Prepare a statement and return a PdoStatement-like object.
*
* @param string $sql SQL query
* @return \Zend\Db\Statement\Mysqli
*/
public function prepare($sql)
{
$this->_connect();
if ($this->_stmt) {
$this->_stmt->close();
}
$stmtClass = $this->_defaultStmtClass;
if (!class_exists($stmtClass)) {
\Zend\Loader::loadClass($stmtClass);
}
$stmt = new $stmtClass($this, $sql);
if ($stmt === \false) {
return false;
}
$stmt->setFetchMode($this->_fetchMode);
$this->_stmt = $stmt;
return $stmt;
}
示例15: __construct
/**
* Constructor.
*
* @param array $config
*/
public function __construct(array $config)
{
if (isset($config['table'])) {
$this->_table = $config['table'];
$this->_tableClass = get_class($this->_table);
}
if (isset($config['rowClass'])) {
$this->_rowClass = $config['rowClass'];
}
if (!class_exists($this->_rowClass)) {
\Zend\Loader::loadClass($this->_rowClass);
}
if (isset($config['data'])) {
$this->_data = $config['data'];
}
if (isset($config['readOnly'])) {
$this->_readOnly = $config['readOnly'];
}
if (isset($config['stored'])) {
$this->_stored = $config['stored'];
}
// set the count of rows
$this->_count = count($this->_data);
$this->init();
}