本文整理汇总了PHP中Pimcore\Tool::classExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Tool::classExists方法的具体用法?PHP Tool::classExists怎么用?PHP Tool::classExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool
的用法示例。
在下文中一共展示了Tool::classExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createClassMappings
/**
* @static
* @return array
*/
public static function createClassMappings()
{
$modelsDir = PIMCORE_PATH . "/models/";
$files = rscandir($modelsDir);
$includePatterns = array("/Webservice\\/Data/");
foreach ($files as $file) {
if (is_file($file)) {
$file = str_replace($modelsDir, "", $file);
$file = str_replace(".php", "", $file);
$class = str_replace(DIRECTORY_SEPARATOR, "_", $file);
if (\Pimcore\Tool::classExists($class)) {
$match = false;
foreach ($includePatterns as $pattern) {
if (preg_match($pattern, $file)) {
$match = true;
break;
}
}
if (strpos($file, "Webservice" . DIRECTORY_SEPARATOR . "Data") !== false) {
$match = true;
}
if (!$match) {
continue;
}
$classMap[str_replace("\\Pimcore\\Model\\Webservice\\Data\\", "", $class)] = $class;
}
}
}
return $classMap;
}
示例2: map
/**
* @param $object
* @param $apiclass
* @param $type
* @param null $options
* @return array|string
* @throws \Exception
*/
public static function map($object, $apiclass, $type, $options = null)
{
if ($object instanceof \Zend_Date) {
$object = $object->toString();
} else {
if (is_object($object)) {
if (Tool::classExists($apiclass)) {
$new = new $apiclass();
if (method_exists($new, "map")) {
$new->map($object, $options);
$object = $new;
}
} else {
throw new \Exception("Webservice\\Data\\Mapper: Cannot map [ {$apiclass} ] - class does not exist");
}
} else {
if (is_array($object)) {
$tmpArray = array();
foreach ($object as $v) {
$className = self::findWebserviceClass($v, $type);
$tmpArray[] = self::map($v, $className, $type);
}
$object = $tmpArray;
}
}
}
return $object;
}
示例3: getInstance
/**
* @param null $adapter
* @return null|Adapter\GD|Adapter\Imagick
* @throws \Exception
*/
public static function getInstance($adapter = null)
{
// use the default adapter if set manually (!= null) and no specify adapter is given
if (!$adapter && self::$defaultAdapter) {
$adapter = self::$defaultAdapter;
}
try {
if ($adapter) {
$adapterClass = "\\Pimcore\\Image\\Adapter\\" . $adapter;
if (Tool::classExists($adapterClass)) {
return new $adapterClass();
} else {
if (Tool::classExists($adapter)) {
return new $adapter();
} else {
throw new \Exception("Image-transform adapter `" . $adapter . "´ does not exist.");
}
}
} else {
if (extension_loaded("imagick")) {
return new Adapter\Imagick();
} else {
return new Adapter\GD();
}
}
} catch (\Exception $e) {
\Logger::crit("Unable to load image extensions: " . $e->getMessage());
throw $e;
}
return null;
}
示例4: determineResourceClass
/**
* determineResourceClass
*
* @param $className
*/
protected function determineResourceClass($className)
{
if (Tool::classExists($className)) {
return $className;
}
return parent::determineResourceClass($className);
}
示例5: checkConfig
/**
* checks configuration and if specified classes exist
*
* @param $config
* @throws OnlineShop_Framework_Exception_InvalidConfigException
*/
protected function checkConfig($config)
{
$tempCart = null;
if (empty($config->cart->class)) {
throw new OnlineShop_Framework_Exception_InvalidConfigException("No Cart class defined.");
} else {
if (Tool::classExists($config->cart->class)) {
$tempCart = new $config->cart->class($config->cart);
if (!$tempCart instanceof OnlineShop_Framework_ICart) {
throw new OnlineShop_Framework_Exception_InvalidConfigException("Cart class " . $config->cart->class . " does not implement OnlineShop_Framework_ICart.");
}
} else {
throw new OnlineShop_Framework_Exception_InvalidConfigException("Cart class " . $config->cart->class . " not found.");
}
}
if (empty($config->pricecalculator->class)) {
throw new OnlineShop_Framework_Exception_InvalidConfigException("No pricecalculator class defined.");
} else {
if (Tool::classExists($config->pricecalculator->class)) {
$tempCalc = new $config->pricecalculator->class($config->pricecalculator->config, $tempCart);
if (!$tempCalc instanceof OnlineShop_Framework_ICartPriceCalculator) {
throw new OnlineShop_Framework_Exception_InvalidConfigException("Cart class " . $config->pricecalculator->class . " does not implement OnlineShop_Framework_ICartPriceCalculator.");
}
} else {
throw new OnlineShop_Framework_Exception_InvalidConfigException("pricecalculator class " . $config->pricecalculator->class . " not found.");
}
}
}
示例6: registerModule
/**
* @param $module
* @throws \Exception
*/
public function registerModule($module)
{
if (Tool::classExists($module)) {
$moduleInstance = new $module();
$moduleInstance->init();
$this->_systemModules[] = $moduleInstance;
} else {
throw new \Exception("unknown module [ {$module} ].");
}
}
示例7: getDataFromEditmode
public static function getDataFromEditmode($data, $pimcoreTagName)
{
$tagClass = '\\Pimcore\\Model\\Object\\ClassDefinition\\Data\\' . ucfirst($pimcoreTagName);
if (\Pimcore\Tool::classExists($tagClass)) {
/**
* @var \Pimcore\Model\Object\ClassDefinition\Data $tag
*/
$tag = new $tagClass();
return $tag->getDataFromEditmode($data);
}
//purposely return null if there is no valid class, log a warning
Logger::warning("No valid pimcore tag found for fieldType ({$pimcoreTagName}), check 'fieldType' exists, and 'type' is not being used in config");
return null;
}
示例8: getInstance
public static function getInstance()
{
if (!self::$instance) {
if (\Pimcore\Tool::classExists("\\Elements\\Logging\\Log")) {
$logger = new \Elements\Logging\Log();
$logger->addWriter(new \Elements\Logging\Writer\LogWriterDb(\Zend_Log::DEBUG));
$logger->addWriter(new \Zend_Log_Writer_Stream(PIMCORE_WEBSITE_PATH . "/var/log/trustedshop.log"));
$systemConfig = \Pimcore\Config::getSystemConfig();
$debugAddresses = explode(',', $systemConfig->email->debug->emailaddresses);
$logger->addWriter(new \Elements\Logging\Writer\LogWriterMail($debugAddresses, "TrustedShop-Importer", "", \Zend_Log::ERR));
self::$instance = $logger;
}
}
return self::$instance;
}
示例9: getOfferedServices
/**
* @return \Pimcore\Model\Object\Objectbrick
*/
public function getOfferedServices()
{
$data = $this->offeredServices;
if (!$data) {
if (\Pimcore\Tool::classExists("\\Pimcore\\Model\\Object\\Subscriptions\\OfferedServices")) {
$data = new \Pimcore\Model\Object\Subscriptions\OfferedServices($this, "offeredServices");
$this->offeredServices = $data;
} else {
return null;
}
}
$preValue = $this->preGetValue("offeredServices");
if ($preValue !== null && !\Pimcore::inAdmin()) {
return $preValue;
}
return $data;
}
示例10: getExtraInformation
/**
* @return \Pimcore\Model\Object\Objectbrick
*/
public function getExtraInformation()
{
$data = $this->extraInformation;
if (!$data) {
if (\Pimcore\Tool::classExists("\\Pimcore\\Model\\Object\\CoreShopCartItem\\ExtraInformation")) {
$data = new \Pimcore\Model\Object\CoreShopCartItem\ExtraInformation($this, "extraInformation");
$this->extraInformation = $data;
} else {
return null;
}
}
$preValue = $this->preGetValue("extraInformation");
if ($preValue !== null && !\Pimcore::inAdmin()) {
return $preValue;
}
return $data;
}
示例11: getProvidersAction
public function getProvidersAction()
{
$gateways = \Omnipay\Tool::getSupportedGateways();
$available = [];
$activeProviders = Model\Configuration::get("OMNIPAY.ACTIVEPROVIDERS");
if (!is_array($activeProviders)) {
$activeProviders = [];
}
foreach ($gateways as $gateway) {
$class = \Omnipay\Common\Helper::getGatewayClassName($gateway);
if (\Pimcore\Tool::classExists($class)) {
if (!in_array($gateway, $activeProviders)) {
$available[] = ["name" => $gateway];
}
}
}
$this->_helper->json(array("data" => $available));
}
示例12: getDefaultAdapter
/**
* @return bool
*/
public static function getDefaultAdapter()
{
$adapters = array("LibreOffice", "Ghostscript");
foreach ($adapters as $adapter) {
$adapterClass = "\\Pimcore\\Document\\Adapter\\" . $adapter;
if (Tool::classExists($adapterClass)) {
try {
$adapter = new $adapterClass();
if ($adapter->isAvailable()) {
return $adapter;
}
} catch (\Exception $e) {
\Logger::warning($e);
}
}
}
return null;
}
示例13: getDefaultAdapter
/**
* @return bool
*/
public static function getDefaultAdapter()
{
$adapters = ["Ffmpeg"];
foreach ($adapters as $adapter) {
$adapterClass = "\\Pimcore\\Video\\Adapter\\" . $adapter;
if (Tool::classExists($adapterClass)) {
try {
$adapter = new $adapterClass();
if ($adapter->isAvailable()) {
return $adapter;
}
} catch (\Exception $e) {
Logger::warning($e);
}
}
}
return null;
}
示例14: factory
/**
* @param $type
* @param $name
* @param $documentId
* @param null $config
* @param null $controller
* @param null $view
* @param null $editmode
* @return mixed
*/
public static function factory($type, $name, $documentId, $config = null, $controller = null, $view = null, $editmode = null)
{
$tagClass = "\\Pimcore\\Model\\Document\\Tag\\" . ucfirst($type);
// this is the fallback for custom document tags using prefixes
// so we need to check if the class exists first
if (!\Pimcore\Tool::classExists($tagClass)) {
$oldStyleClass = "\\Document_Tag_" . ucfirst($type);
if (\Pimcore\Tool::classExists($oldStyleClass)) {
$tagClass = $oldStyleClass;
}
}
$tag = new $tagClass();
$tag->setName($name);
$tag->setDocumentId($documentId);
$tag->setController($controller);
$tag->setView($view);
$tag->setEditmode($editmode);
$tag->setOptions($config);
return $tag;
}
示例15: getElements
/**
* Get all elements containing the content (tags) from the database
*
* @return void
*/
public function getElements()
{
$elementsRaw = $this->db->fetchAll("SELECT * FROM documents_elements WHERE documentId = ?", $this->model->getId());
$elements = array();
foreach ($elementsRaw as $elementRaw) {
$class = "\\Pimcore\\Model\\Document\\Tag\\" . ucfirst($elementRaw["type"]);
// this is the fallback for custom document tags using prefixes
// so we need to check if the class exists first
if (!\Pimcore\Tool::classExists($class)) {
$oldStyleClass = "\\Document_Tag_" . ucfirst($elementRaw["type"]);
if (\Pimcore\Tool::classExists($oldStyleClass)) {
$class = $oldStyleClass;
}
}
$element = new $class();
$element->setName($elementRaw["name"]);
$element->setDocumentId($this->model->getId());
$element->setDataFromResource($elementRaw["data"]);
$elements[$elementRaw["name"]] = $element;
$this->model->setElement($elementRaw["name"], $element);
}
return $elements;
}