classExists() public static method

public static classExists ( $class ) : boolean
$class
return boolean
コード例 #1
0
 /**
  * @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
0
ファイル: Mapper.php プロジェクト: sfie/pimcore
 /**
  * @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
0
ファイル: Image.php プロジェクト: Gerhard13/pimcore
 /**
  * @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
0
 /**
  * determineResourceClass
  *
  * @param $className
  */
 protected function determineResourceClass($className)
 {
     if (Tool::classExists($className)) {
         return $className;
     }
     return parent::determineResourceClass($className);
 }
コード例 #5
0
ファイル: MultiCartManager.php プロジェクト: ascertain/NGshop
 /**
  * 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
0
ファイル: Broker.php プロジェクト: solverat/pimcore
 /**
  * @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
0
ファイル: Service.php プロジェクト: pimcore/pimcore
 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
0
ファイル: Logging.php プロジェクト: ascertain/NGshop
 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
0
ファイル: Subscriptions.php プロジェクト: cometCube/nyt
 /**
 * @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
0
 /**
 * @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
0
ファイル: AdminController.php プロジェクト: coreshop/omnipay
 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
0
ファイル: Document.php プロジェクト: emanuel-london/pimcore
 /**
  * @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
0
ファイル: Video.php プロジェクト: pimcore/pimcore
 /**
  * @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
0
ファイル: Tag.php プロジェクト: solverat/pimcore
 /**
  * @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
0
ファイル: Dao.php プロジェクト: emanuel-london/pimcore
 /**
  * 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;
 }
コード例 #16
0
ファイル: Service.php プロジェクト: pawansgi92/pimcore2
 /**
  * @param null $condition
  * @param null $order
  * @param null $orderKey
  * @param null $offset
  * @param null $limit
  * @param null $groupBy
  * @param null $objectClass
  * @throws \Exception
  */
 public function getObjectList($condition = null, $order = null, $orderKey = null, $offset = null, $limit = null, $groupBy = null, $objectClass = null)
 {
     try {
         $params = array("objectTypes" => array(Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_VARIANT));
         if (!empty($condition)) {
             $params["condition"] = $condition;
         }
         if (!empty($order)) {
             $params["order"] = $order;
         }
         if (!empty($orderKey)) {
             $params["orderKey"] = $orderKey;
         }
         if (!empty($offset)) {
             $params["offset"] = $offset;
         }
         if (!empty($limit)) {
             $params["limit"] = $limit;
         }
         if (!empty($groupBy)) {
             $params["groupBy"] = $groupBy;
         }
         $listClassName = "\\Pimcore\\Model\\Object";
         if (!empty($objectClass)) {
             $listClassName = "\\Pimcore\\Model\\Object\\" . ucfirst($objectClass);
             if (!Tool::classExists($listClassName)) {
                 $listClassName = "\\Pimcore\\Model\\Object";
             }
         }
         $list = $listClassName::getList($params);
         $list->setUnpublished(1);
         $items = array();
         foreach ($list as $object) {
             $item = new Webservice\Data\Object\Listing\Item();
             $item->id = $object->getId();
             $item->type = $object->getType();
             if (method_exists($object, "getPublished")) {
                 $item->published = $object->getPublished();
             }
             $items[] = $item;
         }
         return $items;
     } catch (\Exception $e) {
         \Logger::error($e);
         throw $e;
     }
 }
コード例 #17
0
 public function saveAction()
 {
     $id = $this->getParam("id");
     $data = $this->getParam("data");
     $priceRule = PriceRule::getById($id);
     if ($data && $priceRule instanceof PriceRule) {
         $data = \Zend_Json::decode($this->getParam("data"));
         $conditions = $data['conditions'];
         $actions = $data['actions'];
         $actionInstances = array();
         $conditionInstances = array();
         $actionNamespace = "CoreShop\\Model\\PriceRule\\Action\\";
         $conditionNamespace = "CoreShop\\Model\\PriceRule\\Condition\\";
         foreach ($conditions as $condition) {
             $class = $conditionNamespace . ucfirst($condition['type']);
             if (PimTool::classExists($class)) {
                 $instance = new $class();
                 $instance->setValues($condition);
                 $conditionInstances[] = $instance;
             } else {
                 throw new \Exception(sprintf("Condition with type %s not found"), $condition['type']);
             }
         }
         foreach ($actions as $action) {
             $class = $actionNamespace . ucfirst($action['type']);
             if (PimTool::classExists($class)) {
                 $instance = new $class();
                 $instance->setValues($action);
                 print_r($action);
                 $actionInstances[] = $instance;
             } else {
                 throw new \Exception(sprintf("Action with type %s not found"), $action['type']);
             }
         }
         $priceRule->setValues($data['settings']);
         $priceRule->setActions($actionInstances);
         $priceRule->setConditions($conditionInstances);
         $priceRule->save();
         $this->_helper->json(array("success" => true, "priceRule" => $priceRule));
     } else {
         $this->_helper->json(array("success" => false));
     }
 }
コード例 #18
0
 /**
  * @param $keyId
  * @param $value
  * @return string
  */
 private function getTranslatedValue($keyId, $value)
 {
     $translatedValue = "";
     $keyConfig = Object\KeyValue\KeyConfig::getById($keyId);
     $translatorID = $keyConfig->getTranslator();
     $translatorConfig = Object\KeyValue\TranslatorConfig::getById($translatorID);
     $className = $translatorConfig->getTranslator();
     if (\Pimcore\Tool::classExists($className)) {
         $translator = new $className();
         $translatedValue = $translator->translate($value);
         if (!$translatedValue) {
             $translatedValue = $value;
         }
     }
     return $translatedValue;
 }
コード例 #19
0
ファイル: import.php プロジェクト: ascertain/NGshop
function shutdownHandler($arguments)
{
    if (\Pimcore\Tool::classExists("FatalShutdown_Plugin")) {
        FatalShutdown_Plugin::shutdownHandler($arguments);
    }
}
コード例 #20
0
ファイル: Service.php プロジェクト: elavarasann/pimcore
 /**
  * @param $object
  * @param $data Model\Object\Data\CalculatedValue
  * @return mixed|null
  */
 public static function getCalculatedFieldValue($object, $data)
 {
     if (!$data) {
         return null;
     }
     $fieldname = $data->getFieldname();
     $ownerType = $data->getOwnerType();
     /** @var $fd Model\Object\ClassDefinition\Data\CalculatedValue */
     if ($ownerType == "object") {
         $fd = $object->getClass()->getFieldDefinition($fieldname);
     } else {
         if ($ownerType == "localizedfield") {
             $fd = $object->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition($fieldname);
         } else {
             if ($ownerType == "classificationstore") {
                 $fd = $data->getKeyDefinition();
             } else {
                 if ($ownerType == "fieldcollection" || $ownerType == "objectbrick") {
                     $fd = $data->getKeyDefinition();
                 }
             }
         }
     }
     if (!$fd) {
         return null;
     }
     $className = $fd->getCalculatorClass();
     if (!$className || !\Pimcore\Tool::classExists($className)) {
         \Logger::error("Class does not exsist: " . $className);
         return null;
     }
     if (method_exists($className, 'compute')) {
         $inheritanceEnabled = Model\Object\Concrete::getGetInheritedValues();
         Model\Object\Concrete::setGetInheritedValues(true);
         $result = call_user_func($className . '::compute', $object, $data);
         Model\Object\Concrete::setGetInheritedValues($inheritanceEnabled);
         return $result;
     }
     return null;
 }
コード例 #21
0
 /** Returns the total number of objects matching the given condition
  *  GET http://[YOUR-DOMAIN]/webservice/rest/object-count?apikey=[API-KEY]&condition=type%3D%27folder%27
  *
  * Parameters:
  *      - condition
  *      - group by key
  *      - objectClass the name of the object class (without "Object_"). If the class does
  *          not exist the filter criteria will be ignored!
  */
 public function objectCountAction()
 {
     $this->checkUserPermission("objects");
     $condition = urldecode($this->getParam("condition"));
     $groupBy = $this->getParam("groupBy");
     $objectClass = $this->getParam("objectClass");
     $params = array("objectTypes" => array(Object\AbstractObject::OBJECT_TYPE_FOLDER, Object\AbstractObject::OBJECT_TYPE_OBJECT, Object\AbstractObject::OBJECT_TYPE_VARIANT));
     if (!empty($condition)) {
         $params["condition"] = $condition;
     }
     if (!empty($groupBy)) {
         $params["groupBy"] = $groupBy;
     }
     $listClassName = "\\Pimcore\\Model\\Object\\AbstractObject";
     if (!empty($objectClass)) {
         $listClassName = "\\Pimcore\\Model\\Object\\" . ucfirst($objectClass);
         if (!Tool::classExists($listClassName)) {
             $listClassName = "Pimcore\\Model\\Object\\AbstractObject";
         }
     }
     $count = $listClassName::getTotalCount($params);
     $this->encoder->encode(array("success" => true, "data" => array("totalCount" => $count)));
 }
コード例 #22
0
 /**
  * @param array $config
  * @return mixed
  * @throws \Exception
  */
 public static function getList($config = array())
 {
     if (is_array($config)) {
         $listClass = "\\Pimcore\\Model\\Document\\Listing";
         $listClass = Tool::getModelClassMapping($listClass);
         if (Tool::classExists($listClass)) {
             $list = new $listClass();
             $list->setValues($config);
             $list->load();
             return $list;
         }
     }
     throw new \Exception("Unable to initiate list class - class not found or invalid configuration");
 }
コード例 #23
0
 /**
  * @param array $config
  * @return total count
  */
 public static function getTotalCount($config = array())
 {
     $className = "\\Pimcore\\Model\\Object";
     // get classname
     if (get_called_class() != "Pimcore\\Model\\Object\\AbstractObject" && get_called_class() != "Pimcore\\Model\\Object\\Concrete") {
         $tmpObject = new static();
         $className = "\\Pimcore\\Model\\Object\\" . ucfirst($tmpObject->getClassName());
     }
     if (!empty($config["class"])) {
         $className = "\\" . ltrim($config["class"], "\\");
     }
     if (is_array($config)) {
         if ($className) {
             $listClass = ucfirst($className) . "\\Listing";
             // check for a mapped class
             $listClass = Tool::getModelClassMapping($listClass);
             if (Tool::classExists($listClass)) {
                 $list = new $listClass();
             }
         }
         $list->setValues($config);
         $count = $list->getTotalCount();
         return $count;
     }
 }
コード例 #24
0
 /**
  * @param $array
  * @param bool $throwException
  * @return bool
  * @throws \Exception
  */
 public static function generateLayoutTreeFromArray($array, $throwException = false)
 {
     if (is_array($array) && count($array) > 0) {
         $class = "\\Pimcore\\Model\\Object\\ClassDefinition\\" . ucfirst($array["datatype"]) . "\\" . ucfirst($array["fieldtype"]);
         if (!\Pimcore\Tool::classExists($class)) {
             $class = "\\Object_Class_" . ucfirst($array["datatype"]) . "_" . ucfirst($array["fieldtype"]);
             if (!\Pimcore\Tool::classExists($class)) {
                 $class = null;
             }
         }
         if ($class) {
             $item = new $class();
             if (method_exists($item, "addChild")) {
                 // allows childs
                 $item->setValues($array, array("childs"));
                 if (is_array($array) && is_array($array["childs"]) && $array["childs"]["datatype"]) {
                     $childO = self::generateLayoutTreeFromArray($array["childs"], $throwException);
                     $item->addChild($childO);
                 } else {
                     if (is_array($array["childs"]) && count($array["childs"]) > 0) {
                         foreach ($array["childs"] as $child) {
                             $childO = self::generateLayoutTreeFromArray($child, $throwException);
                             if ($childO !== false) {
                                 $item->addChild($childO);
                             } else {
                                 if ($throwException) {
                                     throw new \Exception("Could not add child " . var_export($child, true));
                                 }
                                 return false;
                             }
                         }
                     }
                 }
             } else {
                 $item->setValues($array);
             }
             return $item;
         }
     }
     if ($throwException) {
         throw new \Exception("Could not add child " . var_export($array, true));
     }
     return false;
 }
コード例 #25
0
 /**
  * @param $className
  */
 protected function determineResourceClass($className)
 {
     $filesToInclude = [];
     $filePath = str_replace(["_", "\\"], "/", $className) . ".php";
     $filesToInclude[] = preg_replace("@^Pimcore/Model/@", "", $filePath);
     $filesToInclude[] = $filePath;
     foreach ($filesToInclude as $fileToInclude) {
         if ($fileToInclude == "Resource.php" || $fileToInclude == "Resource/Mysql.php") {
             return;
         }
         if (File::isIncludeable($fileToInclude)) {
             include_once $fileToInclude;
             if (Tool::classExists($className)) {
                 return $className;
             }
         } else {
             //\Logger::debug("Couldn't find resource implementation " . $className . " for " . get_class($this));
         }
     }
     return;
 }
コード例 #26
0
ファイル: AbstractModel.php プロジェクト: GNi33/pimcore
 /**
  * @param $className
  */
 protected function determineResourceClass($className)
 {
     $filesToInclude = [];
     $filePath = str_replace(["_", "\\"], "/", $className) . ".php";
     $filesToInclude[] = preg_replace("@^Pimcore/Model/@", "", $filePath);
     $filesToInclude[] = $filePath;
     foreach ($filesToInclude as $fileToInclude) {
         if ($fileToInclude == "Dao.php" || $fileToInclude == "Resource.php") {
             return;
         }
         if (File::isIncludeable($fileToInclude)) {
             include_once $fileToInclude;
             if (Tool::classExists($className)) {
                 return $className;
             }
         }
     }
     return;
 }
コード例 #27
0
ファイル: Pimcore.php プロジェクト: pdaniel-frk/pimcore
 /**
  *
  */
 public static function initPlugins()
 {
     // add plugin include paths
     $autoloader = \Zend_Loader_Autoloader::getInstance();
     try {
         $pluginConfigs = ExtensionManager::getPluginConfigs();
         if (!empty($pluginConfigs)) {
             $includePaths = array(get_include_path());
             //adding plugin include paths and namespaces
             if (count($pluginConfigs) > 0) {
                 foreach ($pluginConfigs as $p) {
                     if (!ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) {
                         continue;
                     }
                     if (is_array($p['plugin']['pluginIncludePaths']['path'])) {
                         foreach ($p['plugin']['pluginIncludePaths']['path'] as $path) {
                             $includePaths[] = PIMCORE_PLUGINS_PATH . $path;
                         }
                     } else {
                         if ($p['plugin']['pluginIncludePaths']['path'] != null) {
                             $includePaths[] = PIMCORE_PLUGINS_PATH . $p['plugin']['pluginIncludePaths']['path'];
                         }
                     }
                     if (is_array($p['plugin']['pluginNamespaces']['namespace'])) {
                         foreach ($p['plugin']['pluginNamespaces']['namespace'] as $namespace) {
                             $autoloader->registerNamespace($namespace);
                         }
                     } else {
                         if ($p['plugin']['pluginNamespaces']['namespace'] != null) {
                             $autoloader->registerNamespace($p['plugin']['pluginNamespaces']['namespace']);
                         }
                     }
                 }
             }
             set_include_path(implode(PATH_SEPARATOR, $includePaths));
             $broker = \Pimcore\API\Plugin\Broker::getInstance();
             //registering plugins
             foreach ($pluginConfigs as $p) {
                 if (!ExtensionManager::isEnabled("plugin", $p["plugin"]["pluginName"])) {
                     continue;
                 }
                 $jsPaths = array();
                 $isExtJs5 = \Pimcore\Tool\Admin::isExtJS5();
                 if ($isExtJs5 && is_array($p['plugin']['pluginJsPaths-extjs5']) && isset($p['plugin']['pluginJsPaths-extjs5']['path']) && is_array($p['plugin']['pluginJsPaths-extjs5']['path'])) {
                     $jsPaths = $p['plugin']['pluginJsPaths-extjs5']['path'];
                 } else {
                     if ($isExtJs5 && is_array($p['plugin']['pluginJsPaths-extjs5']) && $p['plugin']['pluginJsPaths-extjs5']['path'] != null) {
                         $jsPaths[0] = $p['plugin']['pluginJsPaths-extjs5']['path'];
                     } else {
                         if (is_array($p['plugin']['pluginJsPaths']) && isset($p['plugin']['pluginJsPaths']['path']) && is_array($p['plugin']['pluginJsPaths']['path'])) {
                             $jsPaths = $p['plugin']['pluginJsPaths']['path'];
                         } else {
                             if (is_array($p['plugin']['pluginJsPaths']) && $p['plugin']['pluginJsPaths']['path'] != null) {
                                 $jsPaths[0] = $p['plugin']['pluginJsPaths']['path'];
                             }
                         }
                     }
                 }
                 //manipulate path for frontend
                 if (is_array($jsPaths) and count($jsPaths) > 0) {
                     for ($i = 0; $i < count($jsPaths); $i++) {
                         if (is_file(PIMCORE_PLUGINS_PATH . $jsPaths[$i])) {
                             $jsPaths[$i] = "/plugins" . $jsPaths[$i];
                         }
                     }
                 }
                 $cssPaths = array();
                 if ($isExtJs5 && is_array($p['plugin']['pluginCssPaths-extjs5']) && isset($p['plugin']['pluginCssPaths-extjs5']['path']) && is_array($p['plugin']['pluginCssPaths-extjs5']['path'])) {
                     $cssPaths = $p['plugin']['pluginCssPaths-extjs5']['path'];
                 } else {
                     if ($isExtJs5 && is_array($p['plugin']['pluginCssPaths-extjs5']) && $p['plugin']['pluginCssPaths-extjs5']['path'] != null) {
                         $cssPaths[0] = $p['plugin']['pluginCssPaths-extjs5']['path'];
                     } else {
                         if (is_array($p['plugin']['pluginCssPaths']) && isset($p['plugin']['pluginCssPaths']['path']) && is_array($p['plugin']['pluginCssPaths']['path'])) {
                             $cssPaths = $p['plugin']['pluginCssPaths']['path'];
                         } else {
                             if (is_array($p['plugin']['pluginCssPaths']) && $p['plugin']['pluginCssPaths']['path'] != null) {
                                 $cssPaths[0] = $p['plugin']['pluginCssPaths']['path'];
                             }
                         }
                     }
                 }
                 //manipulate path for frontend
                 if (is_array($cssPaths) and count($cssPaths) > 0) {
                     for ($i = 0; $i < count($cssPaths); $i++) {
                         if (is_file(PIMCORE_PLUGINS_PATH . $cssPaths[$i])) {
                             $cssPaths[$i] = "/plugins" . $cssPaths[$i];
                         }
                     }
                 }
                 try {
                     $className = $p['plugin']['pluginClassName'];
                     if (!empty($className) && Tool::classExists($className)) {
                         $plugin = new $className($jsPaths, $cssPaths);
                         if ($plugin instanceof \Pimcore\API\Plugin\AbstractPlugin) {
                             $broker->registerPlugin($plugin);
                         }
                     }
                 } catch (\Exception $e) {
                     \Logger::err("Could not instantiate and register plugin [" . $p['plugin']['pluginClassName'] . "]");
                 }
             }
             \Zend_Registry::set("Pimcore_API_Plugin_Broker", $broker);
         }
     } catch (\Exception $e) {
         \Logger::alert("there is a problem with the plugin configuration");
         \Logger::alert($e);
     }
 }
コード例 #28
0
ファイル: Placeholder.php プロジェクト: pimcore/pimcore
 /**
  * Creates the Placeholder objects and replaces the placeholder string
  * with the rendered content of the placeholder object
  *
  * @param array $placeholderStack
  * @return string
  */
 protected function replacePlaceholdersFromStack($placeholderStack = [])
 {
     $stringReplaced = null;
     if (!empty($placeholderStack)) {
         foreach ($placeholderStack as $placeholder) {
             $placeholderObject = null;
             $placeholderClassPrefixes = self::getPlaceholderClassPrefixes();
             $placeholderObject = null;
             foreach ($placeholderClassPrefixes as $classPrefix) {
                 $className = $classPrefix . $placeholder['placeholderClass'];
                 if (Tool::classExists($className)) {
                     $placeholderObject = new $className();
                     break;
                 }
             }
             if (is_null($stringReplaced)) {
                 $stringReplaced = $placeholder['contentString'];
             }
             if ($placeholderObject instanceof Placeholder\AbstractPlaceholder) {
                 //setting values from placeholder stack to placeholder objects
                 foreach (array_keys($placeholder) as $key) {
                     if ($key == 'placeholderClass') {
                         continue;
                     }
                     $placeholderObject->{'set' . ucfirst($key)}($placeholder[$key]);
                 }
                 $placeholderObject->setLocale();
                 $replaceWith = $placeholderObject->getReplacement();
                 if (!isset($replaceWith)) {
                     $replaceWith = $placeholderObject->getEmptyValue();
                 }
                 $stringReplaced = str_replace($placeholderObject->getPlaceholderString(), $replaceWith, $stringReplaced);
             } else {
                 Logger::warn('Ignoring Placeholder "' . $placeholder['placeholderClass'] . '" -> Class not Found or not an instance of Pimcore_Placeholder_Abstract!');
             }
         }
     }
     return $stringReplaced;
 }
コード例 #29
0
 /**
  * @static
  * @param  $sourceClassName
  * @return string
  */
 public static function getModelClassMapping($sourceClassName, $interfaceToImplement = null)
 {
     $targetClassName = $sourceClassName;
     if (!$interfaceToImplement) {
         $interfaceToImplement = $targetClassName;
     }
     if ($map = \CoreShop\Config::getModelClassMappingConfig()) {
         $tmpClassName = $map->{$sourceClassName};
         if ($tmpClassName) {
             if (\Pimcore\Tool::classExists($tmpClassName)) {
                 if (is_subclass_of($tmpClassName, $interfaceToImplement)) {
                     $targetClassName = $tmpClassName;
                 } else {
                     \Logger::error("Classmapping for " . $sourceClassName . " failed. '" . $tmpClassName . " is not a subclass of '" . $interfaceToImplement . "'. " . $tmpClassName . " has to extend " . $interfaceToImplement);
                 }
             } else {
                 \Logger::error("Classmapping for " . $sourceClassName . " failed. Cannot find class '" . $tmpClassName . "'");
             }
         }
     }
     return $targetClassName;
 }
コード例 #30
0
ファイル: View.php プロジェクト: jjpeters67/pimcore
 /**
  * @param string $method
  * @param array $arguments
  * @return mixed|Model\Document\Tag|string
  * @throws \Exception
  */
 public function __call($method, $arguments)
 {
     $class = "\\Pimcore\\Model\\Document\\Tag\\" . ucfirst(strtolower($method));
     $classFound = true;
     if (!\Pimcore\Tool::classExists($class)) {
         $oldStyleClass = "Document_Tag_" . ucfirst(strtolower($method));
         if (!\Pimcore\Tool::classExists($oldStyleClass)) {
             $classFound = false;
         }
     }
     if ($classFound) {
         if (!isset($arguments[0])) {
             throw new \Exception("You have to set a name for the called tag (editable): " . $method);
         }
         // set default if there is no editable configuration provided
         if (!isset($arguments[1])) {
             $arguments[1] = array();
         }
         return $this->tag($method, $arguments[0], $arguments[1]);
     }
     if ($this->document instanceof Model\Document) {
         if (method_exists($this->document, $method)) {
             return call_user_func_array(array($this->document, $method), $arguments);
         }
     }
     return parent::__call($method, $arguments);
 }